ZX81 BASIC, variables, LET statement
Posted: Mon Sep 09, 2013 11:16 pm
The use of the statement LET for assigning variables should be clear in general.
Here an example from the manual:
This allows in conjunction with PRINT to do all calculations, use of mathematical functions and PRINT the result.
This looks like the listing of the ZX81:
There is one speciality I didn't know before and I noticed after studying the corresponding chapter of the manual. The ZX81 supports space characters in label names. I didn't find an easy way to solve it and so I abstained from realizing it. I didn't find this very helpful as there is no distinction between the name with or without spaces. By the way you can do as many spaces as much you like at any position in a variables name. The only rule is, that the variable name has to begin with a letter. Take a look at the following listing:
Here the variable M3 is defined which can be written as M 3 (with space in the middle) as well. So my recommendation is not to use spaces in variable names and I don't know any programming language supporting this feature.
It is possible to use space in variable names using declaration in simple apostrophes. This will be interpreted as string but placed in the program code without the markers for a string (quotes). So the ZX-IDE distincts now between strings place in apostrophes and placed in quotes. Only string placed in quotes will generate the quote markers for the ZX81 to recognize a string.
Here an example from the manual:
Code: Select all
REM VARIABLES TEST
REM
LET EGGS=58
PRINT EGGS
PRINT EGGS/2
PRINT COS(EGGS/12)**2
LET EGGS=61
PRINT EGGS
LET MILK=18.5
PRINT MILK
This looks like the listing of the ZX81:
There is one speciality I didn't know before and I noticed after studying the corresponding chapter of the manual. The ZX81 supports space characters in label names. I didn't find an easy way to solve it and so I abstained from realizing it. I didn't find this very helpful as there is no distinction between the name with or without spaces. By the way you can do as many spaces as much you like at any position in a variables name. The only rule is, that the variable name has to begin with a letter. Take a look at the following listing:
Code: Select all
LET M12M=0
LET 'M 3'=1
PRINT M3
PRINT 'M 3'
CLEAR
It is possible to use space in variable names using declaration in simple apostrophes. This will be interpreted as string but placed in the program code without the markers for a string (quotes). So the ZX-IDE distincts now between strings place in apostrophes and placed in quotes. Only string placed in quotes will generate the quote markers for the ZX81 to recognize a string.
Code: Select all
REM VARIABLES TEST 3
REM
CLEAR
PRINT "HI THERE.I AM YOUR ZX81."
LET EGGS=61
PRINT "THE PRICE OF EGGS IS ";EGGS;" NEW PENCE A DOZEN"
LET A$="DOUBLE GLOUCESTER"
PRINT A$