10 PRINT "PROGRAM FILE 18: THE IF-THEN STATEMENT WITH STRING OPERANDS."
20 PRINT "    ANSI STANDARD 10.2, 10.4"
30 PRINT
40 PRINT "SECTION 18.1: THE IF-THEN STATEMENT WITH STRING OPERANDS."
50 PRINT
60 PRINT "THIS SECTION TESTS THE COMPARISON OF STRING VARIABLES AND"
70 PRINT "CONSTANTS WITH A VARIETY OF VALUES. BOTH RELATIONSHIPS"
80 PRINT "(= AND <>) ARE TESTED FOR EACH PAIR OF VALUES. THE 'V' OR"
90 PRINT "'C' FOLLOWING THE COMPARAND VALUE INDICATES WHETHER IT IS"
100 PRINT "A VARIABLE OR A CONSTANTS."
110 PRINT
120 PRINT "'T' OR 'F' IS PRINTED TO SHOW THE OUTCOME OF THE"
130 PRINT "COMPARISON. FOR INCORRECT COMPARES, AN '*' IS PRINTED"
140 PRINT "NEXT TO THE ERRONEOUS RESULT.  WHEN DISPLAYING COMPARAND"
150 PRINT "VALUES, THE UNDERLINE CHARACTER, '_', IS USED TO REPRESENT"
160 PRINT "THE SPACE CHARACTER (THUS A DISPLAYED 'ONE_BLANK' "
170 PRINT "INDICATES AN INTERNAL VALUE OF 'ONE BLANK')."
171 PRINT "ALSO, THE NULL STRING (LENGTH OF ZERO) IS DENOTED BY THE"
172 PRINT "LABEL '(NULL STRING)'."
180 PRINT
190 PRINT "CHARACTER STRINGS SHOULD TEST EQUAL IF AND ONLY IF THE"
200 PRINT "STRINGS ARE EQUAL IN LENGTH AND CONTAIN IDENTICAL SEQUENCES"
210 PRINT "OF CHARACTERS."
220 PRINT
230 PRINT "                  BEGIN TEST."
240 PRINT
250 PRINT "LEFT";TAB(22);": RIGHT"
260 PRINT "COMPARAND";TAB(19);"V/C: COMPARAND";TAB(42);"V/C";
270 PRINT TAB(47);"=";TAB(51);"<>";TAB(55);"RESULT"
275 PRINT
280 LET R$="PASSED"
300 LET T$="  ABC"
310 LET V$="__ABC"
320 GOSUB 2500
330 LET T$="ABC"
340 LET V$="ABC"
350 GOSUB 2000
360 LET T$="ABC "
370 LET V$="ABC_"
380 GOSUB 2500
390 LET T$="   ABC  "
400 LET V$="___ABC__"
410 GOSUB 2500
420 LET T$=""
430 LET V$="(NULL STRING)"
440 GOSUB 2500
450 LET T$="ABCD"
460 LET V$="ABCD"
470 GOSUB 2500
500 LET T$="   0X9"
510 LET V$="___0X9"
520 GOSUB 3500
530 LET T$="0X9"
540 LET V$="0X9"
550 GOSUB 3500
560 LET T$="0X9  "
570 LET V$="0X9__"
580 GOSUB 3500
590 LET T$=" 0X9  "
600 LET V$="_0X9__"
610 GOSUB 3000
620 LET T$="  "
630 LET V$="__"
640 LET U$="    "
650 LET W$="____"
660 GOSUB 4500
670 LET T$=" "
680 LET V$="_"
690 LET U$=""
700 LET W$="(NULL STRING)"
710 GOSUB 4500
720 LET T$="18 CHARACTERS LONG"
730 LET V$="18_CHARACTERS_LONG"
740 LET U$="18 CHARACTERS LONG"
750 LET W$="18_CHARACTERS_LONG"
760 GOSUB 4000
770 LET U$="18 CHARACTERS LONK"
780 LET W$="18_CHARACTERS_LONK"
790 GOSUB 4500
800 LET T$="!#$%&'()0=+*<>?"
810 LET V$="!#$%&'()0=+*<>?"
820 LET U$="!#$%&'()0=+*<>?"
830 LET W$="!#$%&'()0=+*<>?"
840 GOSUB 4000
850 LET T$=""
860 LET V$="(NULL STRING)"
870 LET U$=""
880 LET W$="(NULL STRING)"
890 GOSUB 4000
900 LET T$="UVWXYZ "
910 LET V$="UVWXYZ_"
920 LET U$="UVWXYZ  "
930 LET W$="UVWXYZ__"
940 GOSUB 4500
1900 PRINT
1910 PRINT "*** TEST ";R$;" ***"
1915 PRINT
1920 PRINT "                  END TEST."
1925 PRINT
1930 PRINT "END PROGRAM 18"
1940 STOP
2000 REM SUBROUTINE TO TEST CONSTANT = VARIABLE
2005 LET B$="T*"
2010 LET A$="T"
2020 LET L$="  OK  "
2030 IF "ABC"<>T$ THEN 2060
2040 LET B$="F"
2050 GOTO 2080
2060 LET R$="FAILED"
2070 LET L$="FAILED"
2080 IF "ABC"=T$ THEN 2120
2090 LET R$="FAILED"
2100 LET L$="FAILED"
2110 LET A$="F*"
2120 GOSUB 2900
2125 GOSUB 5000
2130 RETURN
2500 REM SUBROUTINE TO TEST CONSTANT <> VARIABLE
2505 LET A$="T*"
2510 LET B$="T"
2520 LET L$="  OK  "
2530 IF "ABC"=T$ THEN 2560
2540 LET A$="F"
2550 GOTO 2580
2560 LET R$="FAILED"
2570 LET L$="FAILED"
2580 IF "ABC"<>T$ THEN 2620
2590 LET R$="FAILED"
2600 LET L$="FAILED"
2610 LET B$="F*"
2620 GOSUB 2900
2625 GOSUB 5000
2630 RETURN
2900 REM SUBROUTINE TO PRINT COMPARANDS FOR CONSTANT:VARIABLE
2910 PRINT "ABC";TAB(20);"C : ";V$;TAB(43);"V";
2920 RETURN
3000 REM SUBROUTINE TO TEST VARIABLE = CONSTANT
3005 LET B$="T*"
3010 LET A$="T"
3020 LET L$="  OK  "
3030 IF T$<>" 0X9  " THEN 3060
3040 LET B$="F"
3050 GOTO 3080
3060 LET R$="FAILED"
3070 LET L$="FAILED"
3080 IF T$=" 0X9  " THEN 3120
3090 LET R$="FAILED"
3100 LET L$="FAILED"
3110 LET A$="F*"
3120 GOSUB 3900
3125 GOSUB 5000
3130 RETURN
3500 REM SUBROUTINE TO TEST VARIABLE <> CONSTANT
3505 LET A$="T*"
3510 LET B$="T"
3520 LET L$="  OK  "
3530 IF T$=" 0X9  " THEN 3560
3540 LET A$="F"
3550 GOTO 3580
3560 LET R$="FAILED"
3570 LET L$="FAILED"
3580 IF T$<>" 0X9  " THEN 3620
3590 LET R$="FAILED"
3600 LET L$="FAILED"
3610 LET B$="F*"
3620 GOSUB 3900
3625 GOSUB 5000
3630 RETURN
3900 REM SUBROUTINE TO PRINT COMPARANDS FOR VARIABLE:CONSTANT
3910 PRINT V$;TAB(20);"V : _0X9__";TAB(43);"C";
3920 RETURN
4000 REM SUBROUTINE TO TEST VARIABLE = VARIABLE
4005 LET B$="T*"
4010 LET A$="T"
4020 LET L$="  OK  "
4030 IF T$<>U$ THEN 4060
4040 LET B$="F"
4050 GOTO 4080
4060 LET R$="FAILED"
4070 LET L$="FAILED"
4080 IF T$=U$ THEN 4120
4090 LET R$="FAILED"
4100 LET L$="FAILED"
4120 GOSUB 4900
4125 GOSUB 5000
4130 RETURN
4500 REM SUBROUTINE TO TEST VARIABLE <> VARIABLE
4505 LET A$="T*"
4510 LET B$="T"
4520 LET L$="  OK  "
4530 IF T$=U$ THEN 4560
4540 LET A$="F"
4550 GOTO 4580
4560 LET R$="FAILED"
4570 LET L$="FAILED"
4580 IF T$<>U$ THEN 4620
4590 LET R$="FAILED"
4600 LET L$="FAILED"
4610 LET B$="F*"
4620 GOSUB 4900
4625 GOSUB 5000
4630 RETURN
4900 REM SUBROUTINE TO PRINT COMPARANDS FOR VARIABLE:VARIABLE
4910 PRINT V$;TAB(20);"V : ";W$;TAB(43);"V";
4920 RETURN
5000 REM SUBROUTINE TO PRINT RESULTS OF COMPARE
5010 PRINT TAB(47);A$;TAB(51);B$;TAB(55);L$
5020 RETURN
9000 END
