10 PRINT "PROGRAM FILE 109: STRING INPUT."
20 PRINT "    ANSI STANDARD 3.2, 13.2, 13.4"
30 PRINT
40 PRINT "SECTION 109.1 INPUT OF QUOTED AND UNQUOTED STRINGS"
50 PRINT
60 PRINT "PLEASE ENTER YOUR INPUT-REPLIES EXACTLY AS REQUESTED"
70 PRINT "BY THE PROMPT, INCLUDING ALL SPACING, COMMAS AND OTHER"
80 PRINT "PUNCTUATION."
90 PRINT
100 PRINT " - EXCEPT - WHEREVER THE PROMPT CONTAINS AN EQUALS (=)"
110 PRINT "SUBSTITUTE A BLANK SPACE, AND WHEREVER THE PROMPT"
120 PRINT "CONTAINS A NUMBER-SIGN (#), SUBSTITUTE A QUOTE."
130 PRINT "THUS, THE PROMPT:"
140 PRINT "             ==#ER#=="
150 PRINT "SHOULD CAUSE YOU TO STRIKE THE KEYS:"
160 PRINT "  1. SPACE"
170 PRINT "  2. SPACE"
180 PRINT "  3. QUOTE"
190 PRINT "  4. LETTER E"
200 PRINT "  5. LETTER R"
210 PRINT "  6. QUOTE"
220 PRINT "  7. SPACE"
230 PRINT "  8. SPACE"
240 PRINT
250 PRINT "THESE CONVENTIONS ARE NECESSARY BECAUSE THE QUOTE IS"
260 PRINT "UNPRINTABLE IN MINIMAL BASIC, AND SPACES ARE DIFFICULT"
270 PRINT "TO COUNT ON A TERMINAL."
280 PRINT
290 PRINT "PLEASE NOTE THAT THIS ROUTINE IS STRONGLY DEPENDENT"
300 PRINT "ON THE CORRECT OPERATION OF THE STRING COMPARISON"
310 PRINT "FEATURE. IF THAT FEATURE IS INCORRECT, THIS ROUTINE"
320 PRINT "WILL LIKELY GIVE INVALID RESULTS."
330 PRINT
340 PRINT "ALL THE REPLIES PROMPTED FOR ARE VALID, THEREFOR "
350 PRINT "IF THE PROCESSOR REJECTS ANY OF THEM, "
360 PRINT "***  TEST FAILED  ***"
370 PRINT
380 PRINT "FOR USER CONVENIENCE, THE STRING TO BE ENTERED IS INDENTED"
390 PRINT "TWO SPACES, SO THAT IF THE INPUT-PROMPT OCCUPIES TWO"
400 PRINT "POSITIONS, AS RECOMMENDED, YOUR INPUT-REPLY WILL BE"
410 PRINT "ALIGNED WITH THE PROMPT STRING."
420 PRINT
430 PRINT "                BEGIN TEST"
440 LET F=0
450 READ N,P$
460 LET Q$=""
470 IF N<100 THEN 500
480 LET N=N-100
490 READ Q$
500 IF N=0 THEN 1380
510 LET A$=""
520 LET B$=""
530 LET C$=""
540 LET D$=""
550 LET I$=""
560 LET J$=""
570 LET K$=""
580 LET L$=""
590 READ I$
600 IF N<=1 THEN 660
610 READ J$
620 IF N<=2 THEN 660
630 READ K$
640 IF N<=3 THEN 660
650 READ L$
660 PRINT
670 PRINT
680 PRINT "PLEASE ENTER:"
690 PRINT "  ";P$;Q$
700 ON N GOTO 710,730,750,770
710 INPUT A$
720 GOTO 790
730 INPUT A$,B$
740 GOTO 790
750 INPUT A$,B$,C$
760 GOTO 790
770 INPUT A$,B$,C$,D$
780 GOTO 790
790 REM COMMON EXIT POINT
800 PRINT
810 PRINT "SHOULD BE: ***";I$;J$;K$;L$;"***"
820 PRINT "ACTUAL:    ***";A$;B$;C$;D$;"***"
830 IF A$<>I$ THEN 890
840 IF B$<>J$ THEN 890
850 IF C$<>K$ THEN 890
860 IF D$<>L$ THEN 890
870 PRINT "TEST OK"
880 GOTO 450
890 PRINT "INPUT NOT EQUAL EXPECTED VALUE. RE-TRY (Y OR N)?"
900 INPUT T$
910 IF T$<>"N" THEN 660
920 PRINT "TEST FAILED."
930 LET F=F+1
940 GOTO 450
950 REM DATA ITEM FORMAT:
960 REM  1 - NUMBER OF VARIABLES   (+100 IF LONG PROMPT)
970 REM  2 - PROMPT
980 REM  3 - CORRECT RESULT
990 REM      OR
1000 REM  2,3 - LONG PROMPT
1010 REM  4 - CORRECT RESULT
1020 DATA 1,"ABC","ABC"
1030 DATA 1,"#ABC#","ABC"
1040 DATA 2,"ABC,DEF","ABC","DEF"
1050 DATA 2,"#ABC#,#DEF#","ABC","DEF"
1060 DATA 2,"#ABC#,DEF","ABC","DEF"
1070 DATA 2,"ABC,#DEF#","ABC","DEF"
1080 REM TEST ALL CHARACTERS LEGAL IN UNQUOTED STRING
1090 DATA 1,"ABCDEFGHIJKLM","ABCDEFGHIJKLM"
1100 DATA 1,"NOPQRSTUVWXYZ","NOPQRSTUVWXYZ"
1110 DATA 1,"+.=====-","+.     -"
1120 DATA 1,"----5---10---15-18","----5---10---15-18"
1130 DATA 1,"===ABC","ABC"
1140 DATA 1,"ABC===","ABC"
1150 DATA 1,"===ABC===","ABC"
1160 DATA 1,"#===ABC#","   ABC"
1170 DATA 1,"#ABC===#","ABC   "
1180 DATA 1,"#===ABC===#","   ABC   "
1190 DATA 101,"===#===ABC","====#====","   ABC    "
1200 DATA 103,"===ABC==,===#DEF#","===,==GHI==","ABC","DEF","GHI"
1210 DATA 3,"=1=,==2==,===3===","1","2","3"
1220 DATA 1,"A===B","A   B"
1230 DATA 1,"===A===B===","A   B"
1240 DATA 101,"===EIGHTEEN","=POSITIONS===","EIGHTEEN POSITIONS"
1250 DATA 103,"==A==B==,==C=","=D==,==E==F==","A  B","C  D","E  F"
1260 DATA 103,"==A==B==,","==#D#==,==E==F==","A  B","D","E  F"
1270 DATA 3,"=#A#=,=B=C=,=#D#=","A","B C","D"
1280 DATA 103,"==#==A==B==#==,","=#=C=D=#=,=E=F=","  A  B  "
1290 DATA " C D ","E F"
1300 DATA 4,"A,B,#C,D#,#E#","A","B","C,D","E"
1310 DATA 1,"##",""
1320 DATA 3,"A,##,B","A","","B"
1330 DATA 3,"==A==,==##==,==B==","A","","B"
1340 DATA 1,"AB+3-5.6B","AB+3-5.6B"
1350 DATA 1,"-1.23","-1.23"
1360 DATA 1,"+3-5=-8+6","+3-5 -8+6"
1370 DATA 0,"Q"
1380 PRINT
1390 PRINT
1400 IF F=0 THEN 1430
1410 PRINT "***  TEST FAILED: ";F;" CASE(S) HANDLED IMPROPERLY  ***"
1420 GOTO 1440
1430 PRINT "***  TEST PASSED  ***"
1440 PRINT
1450 PRINT "                  END TEST"
1460 PRINT
1470 PRINT "SECTION 109.2 TEST QUOTED-STRING-CHARACTERS"
1480 PRINT
1490 PRINT "THIS PART OF THE TEST IS INTENDED TO DETERMINE WHETHER"
1500 PRINT "QUOTED STRINGS ON INPUT CAN CONTAIN ANY OF THE LEGAL"
1510 PRINT "QUOTED STRING CHARACTERS."
1520 PRINT
1530 PRINT "PLEASE RESPOND TO THE PROMPT BY ENTERING THE REQUESTED"
1540 PRINT "CHARACTERS IMMEDIATELY PRECEDED AND FOLLOWED BY THE"
1550 PRINT "QUOTE CHARACTER. THUS THE PROMPT:"
1560 PRINT "    ABC"
1570 PRINT "SHOULD CAUSE YOU TO STRIKE THE KEYS:"
1580 PRINT "  1. QUOTE"
1590 PRINT "  2. LETTER A"
1600 PRINT "  3. LETTER B"
1610 PRINT "  4. LETTER C"
1620 PRINT "  5. QUOTE"
1630 PRINT "THUS THE QUOTE TO BE ENTERED IS NOW IMPLICIT AND THE"
1640 PRINT "NUMBER SIGN (#) AND EQUALS SIGN (=) HAVE NO SPECIAL"
1650 PRINT "SIGNIFICANCE."
1660 PRINT
1670 PRINT "             BEGIN TEST"
1680 LET F=0
1690 READ A$
1700 IF A$="Q" THEN 1900
1710 PRINT
1720 PRINT
1730 PRINT "PLEASE ENTER:"
1740 PRINT "   ";A$
1750 INPUT B$
1760 PRINT "SHOULD BE: ***";A$;"***"
1770 PRINT "ACTUAL:    ***";B$;"***"
1780 IF A$<>B$ THEN 1810
1790 PRINT "TEST OK"
1800 GOTO 1690
1810 PRINT "INPUT NOT EQUAL TO EXPECTED VALUE. RE-TRY (Y OR N)?"
1820 INPUT C$
1830 IF C$<>"N" THEN 1710
1840 PRINT "TEST FAILED"
1850 LET F=F+1
1860 GOTO 1690
1870 DATA "ABCDEFGHIJKLM","NOPQRSTUVWXYZ","0123456789"
1880 DATA "!#$%&'()*+,-","./:;<=>?^_","EMBEDDED SPACE"
1890 DATA "Q"
1900 PRINT
1910 IF F=0 THEN 1940
1920 PRINT "*** TEST FAILED. ";F;" CASE(S) HANDLED IMPROPERLY. ***"
1930 GOTO 1950
1940 PRINT "***** TEST PASSED *****"
1950 PRINT
1960 PRINT "               END TEST"
1970 PRINT
1980 PRINT "END PROGRAM 109"
1990 END
