SPIN - variable arrays + .word[] or .byte[] suffix question
Agent420
Posts: 439
This wasn't clear in the manual, and a quick search here didn't bring up anything similar...
If I have a long variable array, then want to access the high/low words from that variable, I thought I could do this:
VAR
· long matrix[noparse][[/noparse]20]
PUB main | x, y
· x := matrix[noparse][[/noparse]1].word[noparse][[/noparse]0]
· y := matrix[noparse][[/noparse]1].word[noparse][[/noparse]1]
But that fails during compilation with an 'Expected end of line' error at the period between matrix[noparse][[/noparse]1] and word[noparse][[/noparse]0]
I'm guessing you cannot combine the two on one line, as I eventually tried this and it worked:
PUB main | x, y, z
· z := matrix[noparse][[/noparse]1]
· x := z.word[noparse][[/noparse]0]
· y := z.word[noparse][[/noparse]1]
Is this even the best way to assign hi/lo words of a variable?· I was going to AND with a mask, but this seemed cleaner.
Post Edited (Agent420) : 5/5/2008 11:38:56 AM GMT
If I have a long variable array, then want to access the high/low words from that variable, I thought I could do this:
VAR
· long matrix[noparse][[/noparse]20]
PUB main | x, y
· x := matrix[noparse][[/noparse]1].word[noparse][[/noparse]0]
· y := matrix[noparse][[/noparse]1].word[noparse][[/noparse]1]
But that fails during compilation with an 'Expected end of line' error at the period between matrix[noparse][[/noparse]1] and word[noparse][[/noparse]0]
I'm guessing you cannot combine the two on one line, as I eventually tried this and it worked:
PUB main | x, y, z
· z := matrix[noparse][[/noparse]1]
· x := z.word[noparse][[/noparse]0]
· y := z.word[noparse][[/noparse]1]
Is this even the best way to assign hi/lo words of a variable?· I was going to AND with a mask, but this seemed cleaner.
Post Edited (Agent420) : 5/5/2008 11:38:56 AM GMT
Comments