View Full Version : store multiple characters in quotes
01-24-2012, 11:05 PM
Is it possible to store multiple chracters in quotes, I noticed that in pbasic you can store a single chracter in a quote like so turns = "S", but when i try to store multiple characters in quotes I get an error is their a way that I can do something like this turns = "LUL" without getting an error.
01-26-2012, 02:50 AM
Depends what you have your turns var set to. Byte will store one letter. Word, two. You're looking for a string var, or an array of bytes equal to your longest string... You can find all the details in the stamp manual.
01-26-2012, 03:59 AM
You could store two characters in a word, but 3 characters takes 24 bits. There's no way you could directly do something like turns = "LUL". If turns happens to be a 3 byte array, you could do something like
if (turns(0) = "L") and (turns(1) = "U") and (turns(2) = "L") then
You could use DATA and READ statements to do something like this which would be called by GOSUB Search. It returns with i set to TableSize if the command isn't found or the index of the command (starting at zero) in the table if it's found.
TableSize CON 2
CmdTable: DATA "LUL", "RUL"
Search: FOR i = 0 TO TableSize-1
FOR j = 0 to 2
if temp <> turns(j) THEN GOTO TryNext
TryNext: NEXT i
i = TableSize