Variable = data
Variable will be set to data. Data can be either a fixed value (such as 157),
another variable, or a sum.
If data is a fixed value, it must be an integer between 0 and 255 inclusive.
If data is a sum, then it may have any of the following operands:
· + (add)
· - (subtract)
· * (multiply)
· & (and)
· | (or)
· # (xor)
· ! (not)
· = (equal)
· <> (not equal)
· < (less than)
· > (greater than)
· <= (less than or equal)
· >= (more than or equal)
The final 6 operands are for checking conditions. They will return FALSE (0) if a
condition is false, or TRUE (255) if the condition is true.
GCBASIC also understands order of operations. If multiple operands are
present, they will be processed in this order:
There are two modes in which variables can be set - byte mode and word mode.
GCBASIC will automatically use a different mode for each calculation, depending
on the type of variable being set. If a byte variable is being set, byte mode will be
used; if a word variable is being set, word mode will be used. If a byte is being
set but the calculation involves numbers larger than 255, word mode can be
used by adding [WORD] to the end of the line.
If you prefer, you can add "LET" to the start of the line. It will not change the
program, but is included for those who are used to including it in other BASIC
'This program is to illustrate the setting of variables.
Chipmunk = 46 'Sets the variable Chipmunk to 46
Animal = Chipmunk 'Sets the variable Animal to the value of
the variable Chipmunk
Bear = 2 + 3 * 5 'Sets the variable Bear to the result of 2
+ 3 * 5, 17.
Sheep = (2 + 3) * 5 'Sets the variable Sheep to the result of
(2 + 3) * 5, 25.
Animal = 2 * Bear 'Sets the variable Animal to twice the
value of Bear.
LargeVar = 321 'LargeVar must be set as a word - see DIM.
Temp = LargeVar / 5 [WORD] 'Note the use of [WORD] to ensure that
the calculation is performed correctly
This site hosted for free by: