What is this structure: w[something]...
CalvinBreen
Posts: 7
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: This would be written in BASIC as (I've used the fastspin dialect, since that's one of the BASICs that runs on the propeller):
Spin 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.