Iterating Over String
John Board
Posts: 371
How does one interate over a string...
For example, in python you might do:
How might I do this in SPIN?
Thanks,
John
For example, in python you might do:
s = "String" for x in s: print x
How might I do this in SPIN?
Thanks,
John
Comments
There's no string type in Spin, but you can define a string as an array of bytes in a DAT block.
But as he said there is no string type, it's just an array of bytes, the string() function just creates this array in-line, but it functions the same as declaring a string in DAT, except it automatically terminates the string with a 0-byte and returns the address of the string.
An alternative:
But then you'll have to reset p every time you do that. It would be better in a method like this:
Basically this is for slowly printing a string, so printing a string to the TV one character at a time, to get that kind of "Typewriter" feel...
Anyway, thanks for the help!
-John