10 PRINT "PROGRAM FILE 95: GENERAL USE OF THE READ, DATA,"
15 PRINT "        AND RESTORE STATEMENTS."
20 PRINT "    ANSI STANDARD 14.2, 14.4"
30 PRINT
40 REM THE FOLLOWING LINES DESCRIBE THE DATA AND READ STRUCTURE OF
50 REM THIS PROGRAM. LINE #1 REPRESENTS THE DATA STRING. LINE #2
60 REM REPRESENTS THE FIRST SERIES OF READ STATEMENTS AND THE TYPE
70 REM (STRING OR NUMERIC) OF VARIABLE. LINE #3 REPRESENTS THE
80 REM SECOND SERIES OF READ STATEMENTS, AFTER THE FIRST RESTORE,
90 REM AND LINE #4, THE THIRD SERIES OF READS. SLASHES DELIMIT
100 REM THE RANGE OF INDIVIDUAL STATEMENTS
110 REM
120 REM LINE #1:   1 A 2 B 3 4/5 C D E/F 6/7 8 9 10/11
130 REM LINE #2:   N S N S/N N N S/S S S S S N/S/ N  N
140 REM LINE #3:   S S S S S S S/S S S S N N S
150 REM LINE #4:   N S S S N
160 REM
170 PRINT "SECTION 95.1: GENERAL SYNTAX AND SEMANTICS OF READ AND DATA"
180 PRINT
190 PRINT "THIS SECTION EXERCISES SOME OF THE GENERAL CAPABILITIES"
200 PRINT "AND PROPERTIES OF THE READ AND DATA STATEMENTS, AS LISTED:"
210 PRINT "  1) READ AND DATA CAN MIX STRING AND NUMERIC DATA"
220 PRINT "  2) CONTROL FALLS THROUGH DATA STATEMENTS WITHOUT EFFECT"
230 PRINT "  3) DATA STATEMENTS MAY BE SCATTERED THROUGHOUT SOURCE"
240 PRINT "  4) READ AND DATA LISTS CAN OVERLAP"
250 PRINT "  5) READ CAN ACCESS DATA ANYWHERE IN SOURCE"
260 PRINT
270 PRINT "                BEGIN TEST"
280 PRINT
290 LET F=0
300 LET W$="READ OK"
310 LET X$="READ FAILED"
320 LET Y$="SHOULD BE:"
330 LET Z$="ACTUAL:   "
340 DATA 1,A,2,B,3,4
350 READ A,A$,B,B$
360 PRINT
370 PRINT Y$,1,"A",2,"B"
380 PRINT Z$,A,A$,B,B$
390 IF A<>1 THEN 450
400 IF A$<>"A" THEN 450
410 IF B<>2 THEN 450
420 IF B$<>"B" THEN 450
430 PRINT W$
440 GOTO 470
450 PRINT X$
460 LET F=F+1
470 READ A,B,C,A$
480 PRINT
490 PRINT Y$,3,4,5,"C"
500 PRINT Z$,A,B,C,A$
510 IF A<>3 THEN 570
520 IF B<>4 THEN 570
530 IF C<>5 THEN 570
540 IF A$<>"C" THEN 570
550 PRINT W$
560 GOTO 590
570 PRINT X$
580 LET F=F+1
590 GOTO 620
600 REM TEST BRANCHING TO A DATA STATEMENT
610 DATA 5,C,D,E
620 DATA F,6
630 DATA 7,8,9,10
640 READ A$,B$,C$,D$,E$,A
650 PRINT
660 PRINT Y$,"D","E","F","6","7",8
670 PRINT Z$,A$,B$,C$,D$,E$,A
680 IF A$<>"D" THEN 760
690 IF B$<>"E" THEN 760
700 IF C$<>"F" THEN 760
710 IF D$<>"6" THEN 760
720 IF E$<>"7" THEN 760
730 IF A<>8 THEN 760
740 PRINT W$
750 GOTO 780
760 PRINT X$
770 LET F=F+1
780 READ A$
790 PRINT
800 PRINT Y$,"9"
810 PRINT Z$,A$
820 IF A$<>"9" THEN 850
830 PRINT W$
840 GOTO 870
850 PRINT X$
860 LET F=F+1
870 READ A,B
880 PRINT
890 PRINT Y$,10,11
900 PRINT Z$,A,B
910 IF A<>10 THEN 950
920 IF B<>11 THEN 950
930 PRINT W$
940 GOTO 970
950 PRINT X$
960 LET F=F+1
970 DATA 11
980 PRINT
990 IF F=0 THEN 1020
1000 PRINT "*** TEST FAILED IN ";F;" CASE(S). ***"
1010 GOTO 1030
1020 PRINT "*** TEST PASSED ***"
1030 PRINT
1040 PRINT "               END TEST"
1050 PRINT
1060 PRINT "SECTION 95.2: RESTORE STATEMENT"
1070 PRINT
1080 PRINT "THIS SECTION TESTS THE CAPABILITY OF THE RESTORE STATEMENT"
1090 PRINT "TO ENABLE READING FROM THE BEGINNING OF THE DATA SEQUENCE."
1100 PRINT "FURTHERMORE, DATA VALUES WHICH WERE ORIGINALLY READ AS"
1110 PRINT "NUMERIC MAY BE SUBSEQUENTLY READ AS STRINGS, AND "
1120 PRINT "VICE-VERSA, AS LONG AS DATA-TYPE IS COMPATIBLE WITH"
1130 PRINT "VARIABLE-TYPE."
1140 PRINT
1150 PRINT "               BEGIN TEST"
1160 LET F=0
1170 PRINT
1180 PRINT "EXECUTE FIRST RESTORE"
1190 RESTORE
1200 READ A$,B$,C$,D$,E$,F$,G$
1210 PRINT
1220 PRINT Y$,"1","A","2","B","3","4","5"
1230 PRINT Z$,A$,B$,C$,D$,E$,F$,G$
1240 IF A$<>"1" THEN 1330
1250 IF B$<>"A" THEN 1330
1260 IF C$<>"2" THEN 1330
1270 IF D$<>"B" THEN 1330
1280 IF E$<>"3" THEN 1330
1290 IF F$<>"4" THEN 1330
1300 IF G$<>"5" THEN 1330
1310 PRINT W$
1320 GOTO 1350
1330 PRINT X$
1340 LET F=F+1
1350 READ A$,B$,C$,D$,A,B,E$
1360 PRINT
1370 PRINT Y$,"C","D","E","F",6,7,"8"
1380 PRINT Z$,A$,B$,C$,D$,A,B,E$
1390 IF A$<>"C" THEN 1480
1400 IF B$<>"D" THEN 1480
1410 IF C$<>"E" THEN 1480
1420 IF D$<>"F" THEN 1480
1430 IF A<>6 THEN 1480
1440 IF B<>7 THEN 1480
1450 IF E$<>"8" THEN 1480
1460 PRINT W$
1470 GOTO 1500
1480 PRINT X$
1490 LET F=F+1
1500 PRINT
1510 PRINT "EXECUTE SECOND RESTORE"
1520 RESTORE
1530 PRINT
1540 READ A,A$,B$,C$,B
1550 PRINT
1560 PRINT Y$,1,"A","2","B",3
1570 PRINT Z$,A,A$,B$,C$,B
1580 IF A<>1 THEN 1650
1590 IF A$<>"A" THEN 1650
1600 IF B$<>"2" THEN 1650
1610 IF C$<>"B" THEN 1650
1620 IF B<>3 THEN 1650
1630 PRINT W$
1640 GOTO 1670
1650 PRINT X$
1660 LET F=F+1
1670 PRINT
1680 PRINT
1690 IF F=0 THEN 1720
1700 PRINT "*** TEST FAILED IN ";F;" CASE(S). ***"
1710 GOTO 1730
1720 PRINT "*** TEST PASSED ***"
1730 PRINT
1740 PRINT "              END TEST"
1750 PRINT
1760 PRINT "END PROGRAM 95"
1770 END
