An expression using AND or OR like this is called a conditional expression.
An example using OR could be:
price=price_less_tax*(1.15 OR v$="zero
rated")
Notice how AND tends to go with addition (because its default value is 0), and OR tends to go with multiplication (because its default value is 1).
You can also make string valued conditional expressions, but only using AND.
| x$ AND y has the value | { | x$ if y is non-zero |
| "" if y is zero |
So it means x$ if y (else the empty string).
Try this program, which inputs two strings and puts them in alphabetical order:
10 INPUT "Type in two
strings"'a$,b$
20 IF a$>b$ THEN
c$=a$:a$=b$:b$=c$
30 PRINT a$;" ";("<" AND a$
<b$)+("=" AND a$=b$);
" ";b$
40 GO TO 10
NextBASIC can sometimes work along different lines from English. Consider, for instance, the English clause If a doesn't equal b or c. How would you write this in NextBASIC? The answer is not:
IF a<>b OR c
nor is it
IF a<>b OR a<>c
ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.