String Formatting?
Started by Xenthera, Dec 23 2012 11:28 AM
4 replies to this topic
#1
Posted 23 December 2012 - 11:28 AM
Hi there, I'm working on a seven segment display that's all digital. Right now i'm trying to set a system where you can display the number you typed over 3 displays. I'm also using rednet to accomplish this. My problem is I can only send each display a variable of 0-9. So sending "593" would not work. So if I can take that and split it up into "5" "9" and "3" that would be great. I just don't know how to do that. Any help would be useful.
#2
Posted 23 December 2012 - 11:34 AM
you want string.sub
if str is "5689" then
tonumber(string.sub(str,1,1))
will return 5
and
tonumber(string.sub(str,2,2))
will return 6
etc
if str is "5689" then
tonumber(string.sub(str,1,1))
will return 5
and
tonumber(string.sub(str,2,2))
will return 6
etc
#3
Posted 23 December 2012 - 11:43 AM
What does the third number relate to? string.sub([string],[character position],[?])
#5
Posted 23 December 2012 - 11:55 AM
Thanks. It worked great!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











