would give the output:
WOOF
We use the comparison symbols of mathematics for string comparisons. All the following logical
statements expressions are both permissible and true.
"ALF" < "BEN"
"KIT" > "BEN"
"KIT" <= "LEN"
"KIT" >= "KIT"
"PAT" >= "LEN"
"LEN" <= "LEN"
"PAT" <> "PET"
So far comparisons based simply on internal codes make sense, but data is not always conveniently
restricted to upper case letters. We would like, for example:
Cat to be less than COT
and K2N to be less than K27N
A simple character by character comparison based on internal codes would not give these results, so
SuperBASIC behaves in a more intelligent way. The following program, with suggested input and the
output that will result, illustrates the rules for comparison of strings.
100 REMark comparisons
110 REPeat comp
120 INPUT "input a string" ! first$
130 INPUT "input another string" ! second$
140 IF first$ < second$ THEN PRINT "Less"
150 IF first$ > second$ THEN PRINT "Greater"
160 IF first$ = second$ THEN PRINT "Equal"
170 END REPeat comp
> Greater than - Case dependent comparision, numbers compared in numerical order
< Less than - Case dependent, numbers compared in numerical order
= Equals - Case dependent, strings must be the same
== Equivalent - String must be 'almost' the same, Case independent, numbers compared in numerical
order
>= Greater than or equal to - Case dependent, numbers compared in numerical order
<= Less than or equal to Case dependent, numbers compared in numerical order.