Sinclair ZX81 User Manual page 16

Hide thumbs Also See for ZX81:
Table of Contents

Advertisement

RADIO 33
X
K9P
but these are not:
3 BEARS (begins with a digit)
TALBOT? (? is not a letter or a digit)
.
FOTHERINGTON-THOMAS (- is not a letter or a digit)
Now type
CLEAR
&
PRINT EGGS
You will get report 2 (variable not found) again. The effect of CLEAR is to release all the storage space
that had been reserved for variables - then every variable is as though it had never been defined. Turning
the computer off & on will also do this - but then it doesn't remember anything at all when it is turned back
on.
Expressions can contain the name of a variable anywhere they can have a number.
Note : In some versions of BASIC you are allowed to omit LET & just type in (say)
EGGS=58
This is not allowed on the ZX81. In any case, you'd find it rather difficult to type in.
Also in some versions, only the first two characters in a name are checked, so that RADIO 3 & RADIO
33 would count as the same name; & in some others a variable name must be a letter followed by a digit.
Neither of these restrictions applies to the ZX81.
Yet again, in some versions of BASIC, if a variable has not yet appeared on the left-hand side of a LET
statement then it is assumed to have a value 0. As you saw above with PRINT MILK, this is not so on the
ZX81.
Summary
Variables
Statements: LET , CLEAR
Exercises
1. Why do variable names (that is to say, names of variables) have to begin with a letter?
2. If you're unfamiliar with raising to powers (
At its most elementary level, 'A
sense if B is a positive whole number. To find a definition that works for other values of B, we consider the
rule
**
**
A
(B+C) = A
You should not need much convincing that this works when B & C are both positive whole numbers, but
if we decide that we want it to work even when they are not, then we find ourselves compelled to accept
that
**
= 1
A
0
**
A
(-B)
= 1/A
**
A
(1/B)
= the Bth root of A
&
(inverse video characters not allowed)
**
B' means 'A multiplied by itself B times', but obviously this only makes
**
B * A
C
**
B
**
, shifted H) then do this exercise.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents