Example Explained
Here (again) is what a LET
statement does:
- Finds memory for each new
variable in the statement.
A zero will be placed in numeric variables if there is no
other information. (If there are no new variables, this step does nothing.)
- Does the calculation on the right
of the equal sign.
(If there is nothing to calculate, it just uses the value that is there.)
- Replaces the contents of the variable to the
left of the equal sign
with the result of the calculation.
Here (again) is the example program:
' LET example
LET A = 2
LET B = 4
LET C = (A + B) / 2
PRINT A, B, C
END
The first statement:
- Finds memory for A.
- Uses the value 2.
- Stores the 2 in A.
The second statement:
- Finds memory for B.
- Uses the value 4.
- Stores the 4 in B.
The third statement:
- Finds memory for C. (A and B need no new memory.)
- Does the calculation: (A + B) / 2
- Stores the result 3 in C.
Finally the PRINT looks in each of A, B, C and writes out the contents.