| Code: <HTML> <HEAD><TITLE>Ternary Converter</TITLE> <META HTTP-EQUIV="Content-Language" content="en"> <META HTTP-EQUIV="Content-Type" content="text/html; charset=utf-8"> <SCRIPT type="text/javascript" src="Rgrid.js"></SCRIPT> <SCRIPT type="text/javascript" src="robot1.js"></SCRIPT> </HEAD> <BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#000080> <center><h1>Balanced Ternary Converter</h1></center> <p id="here" align=center>Rgrid requires a modern web-browser to work properly...</p> <p align=center> <table> <tr> <td width=400><font color=#0000AA>Balanced Ternary (N,O,P)</font></td> <td width=400 align=right><input type=text id=input3 size=36 onchange="$R.event(0,-303,$_('input3'))"></td> </tr> <tr> <td width=400><font color=#0000AA>Balanced Nonary (D,C,B,A,0,1,2,3,4)</font></td> <td width=400 align=right><input type=text id=input9 size=36 onchange="$R.event(0,-309,$_('input9'))"></td> </tr> <tr> <td width=400><font color=#0000AA>Balanced Septemvigesimal (N-Z,0-9,A-D)</font></td> <td width=400 align=right><input type=text id=input27 size=36 onchange="$R.event(0,-327,$_('input27'))"></td> </tr> <tr> <td width=400><p id="output">0</p></td> <td width=400 align=right> <input type=checkbox id=inputbct onchange="$R.event(0,-400,$_('inputbct'))"> BCT* <input type=radio name=limit id=radio16 checked onchange="$R.event(0,-116,$_('radio16'))"> 16-bit <input type=radio name=limit id=radio32 onchange="$R.event(0,-132,$_('radio32'))"> 32-bit <input type=radio name=limit id=radio64 onchange="$R.event(0,-164,$_('radio64'))"> 64-bit </td> </tr> <tr> <td width=400>Binary (0,1)</td> <td width=400 align=right><input type=text id=input2 size=36 onchange="$R.event(0,-202,$_('input2'))"></td> </tr> <tr> <td width=400>Octal (0,1,2,3,4,5,6,7)</td> <td width=400 align=right><input type=text id=input8 size=36 onchange="$R.event(0,-208,$_('input8'))"></td> </tr> <tr> <td width=400>Hexadecimal (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)</td> <td width=400 align=right><input type=text id=input16 size=36 onchange="$R.event(0,-216,$_('input16'))"></td> </tr> <tr> <td width=400>Decimal (0,1,2,3,4,5,6,7,8,9) with sign</td> <td width=400 align=right><input type=text id=input10 size=36 onchange="$R.event(0,-210,$_('input10'))"></td> </tr> <tr> <td colspan=2 align=center> <input type=button value="inc" onclick="$R.event(0,-300,1)"> <input type=button value="dec" onclick="$R.event(0,-300,2)"> <input type=button value="mul 3" onclick="$R.event(0,-300,3)"> <input type=button value="div 3" onclick="$R.event(0,-300,4)"> <input type=button value="Any Op =>" onclick="$R.event(0,-300,5)"> <select name="one" id="op1" onchange="$R.event(0,-331,$_('op1'))"> <option value="N" selected>N</option> <option value="O">O</option> <option value="P">P</option> </select> <select name="two" id="op2" onchange="$R.event(0,-332,$_('op2'))"> <option value="N">N</option> <option value="O" selected>O</option> <option value="P">P</option> </select> <select name="three" id="op3" onchange="$R.event(0,-333,$_('op3'))"> <option value="N">N</option> <option value="O">O</option> <option value="P" selected>P</option> </select> </td> </tr> </table> <font size=-1> * Binary Coded Ternary (BCT) represents every trit by 2 bits: N->10, O->00, P->01 (and 11 means ERROR) </font> </p> <p id="pow" align=center>Powered...</p>
<font size=1 color=#808080> <p id="after"> <br> </p> </font>
</BODY> <script type="text/javascript">
$R.prefix = "ternary/";
$_("pow","Powered by " + $R.powered());
function command1(r) { $append("after","Robot "+r.regs[9]+" : "+r.regs[0xA]+" "+r.regs[0xB]+" "+r.regs[0xC]+"<br>"); }
function command2(r) { var id = r.regs[0xA]; var len = r.regs[0xB]; var adr = r.regs[0xC]; var str = ""; var i,j; for(i=0;i<len;i++) { str += String.fromCharCode($R.read(r,adr++)); } if(id>=0) { $_('output',str); } else { j = -id; if(id>-100) { j -= 100; $_("radio"+j,"1"); } else if(id>-200) { j -= 200; $_("input"+j,str); } else // <= -300 { j -= 300; $_("input"+j,str); } } }
$R.callback(1,command1); $R.callback(2,command2);
function action(x,y) { $R.event(0,-1,1,x,y); }
if($R.grid('here',18,2,action)>0) { $map($$("rtab.*.*"),function(e){e.width=45;e.height=45;}); $R.add(robot); $R.start(); }
</script> </HTML>
| |