10 PRINT "PROGRAM FILE 49: NESTED FOR-BLOCKS."
20 PRINT "    ANSI STANDARD 11.2, 11.4"
30 PRINT
40 PRINT "SECTION 49.1: NESTED FOR-BLOCKS."
50 PRINT
60 PRINT "THIS SECTION TESTS THAT FOR-BLOCKS MAY BE NESTED IN THE"
70 PRINT "TEXT OF THE PROGRAM, WITH SEPARATE CONTROL MAINTAINED"
80 PRINT "FOR EACH CONTROL-VARIABLE."
90 PRINT
100 LET S1=0
110 PRINT "               BEGIN TEST."
120 LET T2=204
130 LET E$="ENTERING FOR-BLOCK"
140 LET F$="EXITING FOR-BLOCK"
150 PRINT
160 PRINT "EACH DETAIL LINE REPORTS:"
170 PRINT "   1) DEPTH OF NESTING"
180 PRINT "   2) CORRECT VALUE FOR CONTROL VARIABLE"
190 PRINT "   3) ACTUAL VALUE OF CONTROL VARIABLE"
200 PRINT "   4) RESULT (OK OR FAILED)"
210 PRINT
220 PRINT "DETAIL LINES ARE INDENTED TO SHOW DEPTH OF NESTING."
230 PRINT
240 LET T1=0
250 LET I2=12
260    PRINT E$;" 1"
270    FOR I1=12 TO 0 STEP -1
280    LET T1=T1+1
290    LET J2=-1
300       PRINT E$;" 2"
310       FOR J1=-1 TO 0
320       LET T1=T1+1
330       GOSUB 1070
340       LET J2=J2+1
350       NEXT J1
360       PRINT F$;" 2"
370    GOSUB 1070
380    LET K2=1
390       PRINT E$;" 3"
400       FOR K1=1 TO 3
410       LET T1=T1+1
420       LET J2=I2
430          PRINT E$;" 4"
440          FOR J1=I1 TO 1 STEP -2
450          LET T1=T1+1
460          GOSUB 1070
470          LET J2=J2-2
480          NEXT J1
490          PRINT F$;" 4"
500       GOSUB 1070
510       GOSUB 1140
520       LET K2=K2+1
530       NEXT K1
540       PRINT F$;" 3"
550    GOSUB 1140
560    GOSUB 1000
570    LET I2=I2-1
580    NEXT I1
590    PRINT F$;" 1"
600 GOSUB 1000
610 LET M$="  OK  "
620 IF T1=T2 THEN 650
630 LET M$="FAILED"
640 LET S1=1
650 PRINT
660 PRINT "NO. TIMES THROUGH LOOPS:"
670 PRINT "SHOULD BE: ";T2;"     ACTUAL: ";T1;"   RESULT: ";M$
680 PRINT
690 IF S1=0 THEN 720
700 PRINT "*** TEST FAILED ***"
710 GOTO 730
720 PRINT "*** TEST PASSED ***"
730 PRINT
740 PRINT "               END TEST."
750 PRINT
760 PRINT "END PROGRAM 49"
770 STOP
1000 REM SUBROUTINE TO CHECK THAT I1=I2
1010 LET M$="  OK  "
1020 IF I1=I2 THEN 1050
1030 LET M$="FAILED"
1040 LET S1=1
1050 PRINT 1;TAB(10);I2;TAB(20);I1;TAB(30);M$
1060 RETURN
1070 REM SUBROUTINE TO CHECK THAT J1=J2
1080 LET M$="  OK  "
1090 IF J1=J2 THEN 1120
1100 LET M$="FAILED"
1110 LET S1=1
1120 PRINT TAB(2);2;TAB(12);J2;TAB(22);J1;TAB(32);M$
1130 RETURN
1140 REM SUBROUTINE TO CHECK THAT K1=K2
1150 LET M$="  OK  "
1160 IF K1=K2 THEN 1190
1170 LET M$="FAILED"
1180 LET S1=1
1190 PRINT TAB(4);3;TAB(14);K2;TAB(24);K1;TAB(34);M$
1200 RETURN
1210 END
