"[interpolation]"
"aardvark"
"aasvogel"
"zoo"
"zoology"
Here is the rule for finding out which order two strings come in. First, compare the first characters. If they are different, then one of them has its code less than the other, and the string it came from is the earlier (lesser) of the two strings. If they are the same, then go on to compare the next characters. If in this process one of the strings runs out before the other, then that string is the earlier, otherwise they must be equal.
The relations =, <, >, <=, >= and <> are used for strings as well as for numbers: < means comes before and > means comes after, so that:
"AA man"<"AARDVARK"
"AARDVARK">"AA man"
are both true.
<= and >= work the same way as they do for numbers, so that:
"The same string"<="The same string"
is true, but:
"The same string"<"The same string"
is false.
Experiment on all this using the program here, which inputs two strings and puts them in order.
10 INPUT "Type in two
strings:", a$, b$
20 IF a$>b$ THEN a$,b$=b$,a$
30 PRINT a$;" ";
40 IF a$<b$ THEN PRINT "<";:
GO TO 60
50 PRINT "=";
60 PRINT " ";b$
70 GO TO 10
Note how we are using a multiple assignment in order to swap a$ and b$ in line 20 as
a$=b$:b$=a$
would not have the desired effect since a$ would have the value of b$ prior to trying to assign its value to b$.
This program sets up user-defined graphics to show chess pieces:
P for pawn
R for rook
N for knight
B for bishop
K for king
Q for queen
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.