That print statement should be executed so long as the system is getting redstone input to the right at nearly the exact time it finishes transmitting a character out the rear. However, the odds of the timing actually being "accurate" enough to accomplish that is remote.
You
might be able to get away with something like this:
while not rs.getInput("right") do os.pullEvent("redstone") end -- Wait until the redstone input on the right turns on.
while rs.getInput("right") do
timer=timer+1
sleep(0.1)
end
print(string.char(timer))
timer=0
... however, I still suspect that the timing of things won't be accurate enough to get reliable data, as server tick speeds can vary and so forth.
You could instead use bundled cables. These allow you to send 16 bits of data down the wire instead of the one that a regular redstone wire gives you, which is enough to send at least a couple of basic ASCII characters at a time.
Another option is the "Analog" functions in the redstone API, which allows 16 bits of data over a regular redstone wire.
Regardless as to how you want to try it, I strongly recommend the use of
os.pullEvent() to detect when the redstone inputs are turning off or on.
Edit: Oh, and string.byte() has its own system for dealing with segments of a string. string.byte(s,a,a) is perfectly fine on its own.
Edited by Bomb Bloke, 21 December 2013 - 06:16 PM.