EasyManuals Logo

Sinclair ZX81 User Manual

Sinclair ZX81
92 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #29 background imageLoading...
Page #29 background image
is which, because the thin end points to the number that is supposed to be smaller.
<=
(shifted R - do not type it as < followed by =) means 'is less than or equal to', so that it is like < except
that it holds even if the two numbers are equal: this 2<=2 holds, but 2<2 does not.
>=
(shifted Y) means 'is greater than or equal to' & is similarly like >.
<>
(shifted T) means 'is not equal to' the opposite in meaning to =.
All six of these relational operations have priority 5.
Mathematicians usually write <=, >= and <> as , and . They also write things like '2<3<4' to mean
'2<3 and 3<4', but this is not
possible in BASIC.
These relations can be combined using the logical operations
AND
,
OR
&
NOT
.
one relation
AND
another relation
is true whenever both relations are true.
one relation
OR
another
is true whenever one of the two relations is true (or both are).
NOT
relation
is true whenever the relation is false and is false whenever the relation is true.
Logical expressions can be made with relations &
AND
,
OR
&
NOT
just as numerical expressions can
be made with numbers & +, - and so on; you can even put in brackets if necessary.
NOT
has priority 4,
AND
3 &
OR
2.
Since (unlike other functions)
NOT
has fairly low priority, its argument does not need brackets unless it
contains
AND
or
OR
; so
NOT
A = B means
NOT
(A = B) (which is the same as A <> B).
To illustrate this, clear the computer & try this program.
10
INPUT
F$
20
INPUT
AGE
30
IF
F$="X"
AND
AGE<18
OR
F$="AA"
AND
AGE<14
THEN PRINT
"DONT";
40
PRINT
"LET IN."
50
GOTO
10
Here F$ is supposed to be the category if a film - X for 18 years old & over, AA for 14 & over, & A or U
for anyone, & the program works out whether a person of a given age is to be allowed to see the film.
Lastly, we can compare not only numbers, but also strings. We have seen '=' used in 'F$="X"', & you can
even use the other five, < & so on.
So what does 'less than' mean for strings? One thing it does not mean is 'shorter than', so don't make
that mistake. We make the definition that one string is less than another if it comes first in alphabetical
order: thus
all hold.
<=
means 'is less than or equal to', & so on, just as for numbers.
Note
: In some versions of BASIC - but not on the ZX81 -, the
IF
statement can have the form
IF
condition
THEN
line number
This means the same as
"SMITH" < "SMYTHE"
"SMYTHE" > "SMITH"
"BLOGGS" < "BLOGGS-BLACKBERRY"
"BILLION" < "MILLION"
"TCHAIKOVSKY" < "WAGNER"
"DOLLAR" < "POUND"

Other manuals for Sinclair ZX81

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Sinclair ZX81 and is the answer not in the manual?

Sinclair ZX81 Specifications

General IconGeneral
ProcessorZilog Z80A
Processor Speed3.25 MHz
ROM8 KB
InputMembrane keyboard
StorageCassette tape
Power Supply9V DC
Dimensions167 mm x 40 mm x 175 mm
Release Year1981
ManufacturerSinclair Research
Weight350 g
Operating SystemSinclair BASIC
RAM1 KB
PortsTV out, expansion port
DisplayTelevision (RF modulator output)

Related product manuals