Programming: Did You Know?

See all articles from ZX-Appeal Nov 86
Author(s): Dick Wagner
Publication: ZX-Appeal
Pub Details: ZX-Appeal Nov 86
Date: November 1986
Pages: 15

Most BASICs will compare strings as to <,=,>, and combinations of these operators. I was surprised to learn that Sinclair BASIC will indeed do this, that is, test one string against another string by using relational symbols. Try this simple test with your 1000 or 2068 computer:

10 LET A$="ABC"
20 IF A$ > "GO" THEN PRINT "ABC IS GREATER THAN GO"
30 IF "GO+0"> A$ THEN PRINT" GO0 IS GREATER THAN ABC"
40 IF "SALLY" < "GLENDA" THEN GO TO 1000
50 IF "GLENDA"> "SALLY" THEN GO TO 1010
1000 PRINT "SALLY = 389 WHILE GLENDA = 427"
1005 REM FOR T/S 1000 SALLY = 244 AND GLENDA = 265
1007 STOP
1010 PRINT "GLENDA IS GREATER THAN SALLY"

You will observe that this method compares on the basis of character weight in terms of ASCII value (or TS 1000 character value). This also works for comparing string arrays.

Reprinted from the October issue of “The Plotter” – the newsletter of Clackamas County Area T/S Users Group.