Confusion about Strings
Lucky
Posts: 98
As of right now, I have a lookupz table, filled with values such as "Shift", "Up", "F9". The problem is that when I increment the index, the program does not print on the screen everything between the parentheses at once. It goes S, h, i, f, t, U, p, F, 9, etc. I assign the value to a byte and print it out using the debug.tx method from the fullduplexserial object. Is there a way to print out the whole string of characters in the word at once?
······································································································································································· -Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"You do not really understand something unless you can explain it to your grandmother."
-Lucky[size=-1][/size]
······································································································································································· -Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"You do not really understand something unless you can explain it to your grandmother."
-Lucky[size=-1][/size]
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
here is a democode that shows two ways how to do that
pay attention to the terminating zero of the DAT-section strings
best regards
Stefan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"You do not really understand something unless you can explain it to your grandmother."
-Lucky[size=-1][/size]
DAT
· str1 byte "Shift", 0
· str2 byte "Up", 0
· str3 byte "F9", 0
· table long @str1, @str2, @str3
You could then select one of the strings and print it with the following statement:
· ser.str(@@table[noparse][[/noparse]index])
The @@ is required because spin stores relative addresses for str1, str2 and str3 in the table arrary.· @@ is needed to add the correct offset to get the absolute addresses.· At least I think that is right.· Could somebody verify that for me.
Now where was that thread that said that Spin was a simple language for beginners?
that's why it's called "zero-terminated" strings.
So if you want to have the string "Shift Up Left"
you code
you can make the string as long as the 32kB lasts
if you want three different strings you code
best regards
Stefan
Output is