What is this structure: w[something]...
in Propeller 1
Hello,
I am muddling through .spin and would like to know what this structure represents, in plain English please.
w[btm_line]:=((?rand & $07) * 8)
I am familiar with BASIC from the 80's and this statement has me stumped. Clearly something (an array?) is being defined as being equal to a random number, which is logically combined to $07 for some reason, etc . Any help would be appreciated.
Thank you.
KB
I am muddling through .spin and would like to know what this structure represents, in plain English please.
w[btm_line]:=((?rand & $07) * 8)
I am familiar with BASIC from the 80's and this statement has me stumped. Clearly something (an array?) is being defined as being equal to a random number, which is logically combined to $07 for some reason, etc . Any help would be appreciated.
Thank you.
KB

Comments
dgately
The rest should be straightforward if you remember that the assignment statement is written using ":=" rather than just an equal sign.
KB
"x := y" changes the variable (or array element) x to have the value y.
Here's how to initialize an array so that each element is equal to 0:
VAR long a[8] ' an array of 8 longs PUB cleara | i repeat i from 0 to 7 a[i] := 0This would be written in BASIC as (I've used the fastspin dialect, since that's one of the BASICs that runs on the propeller):dim a(7) ' an array of 8 integers, indexed from 0 to 7 sub cleara dim i for i = 0 to 7 a(i) = 0 next i end subSpin borrows Pascal's assignment operator for variables. For constants as single = sign is used. To test for equality, use ==. For example: This will set z to true if x and y are equal, false otherwise.