10 PRINT "PROGRAM FILE 48: LIMIT AND INCREMENT IN THE FOR-STATEMENT"
20 PRINT "        ARE EVALUATED ONCE UPON ENTERING THE LOOP."
30 PRINT "    ANSI STANDARD 11.2, 11.4"
40 PRINT
50 PRINT "SECTION 48.1: LIMIT AND INCREMENT IN THE FOR-STATEMENT"
60 PRINT "        ARE EVALUATED ONCE UPON ENTERING THE LOOP."
70 PRINT
80 REM S1 IS ERROR SWITCH
90 LET S1=0
100 PRINT "               BEGIN TEST."
110 LET I1=-20
120 LET I2=-20
130 LET T2=1
140 PRINT
150 PRINT "I1 SET TO -20"
160 PRINT "LOOP IS: FOR I1=I1 TO I1 STEP -3"
170 PRINT
180 PRINT "CONTROL VARIABLE:"
190 PRINT "SHOULD BE","ACTUAL","RESULT"
200 LET T1=0
210 FOR I1=I1 TO I1 STEP -3
220 LET T1=T1+1
230 GOSUB 3120
240 IF T1>20 THEN 290
250 LET I2=I2-3
260 NEXT I1
270 PRINT "LOOP EXITED"
280 GOTO 310
290 PRINT "JUMPED OUT OF LOOP: INCORRECT"
300 LET S1=1
310 GOSUB 3120
320 GOSUB 3000
400 LET I1=-3
410 LET I2=-3
420 LET T2=6
430 PRINT
440 PRINT "I1 SET TO -3"
450 PRINT "LOOP IS: FOR I1=I1 TO -20 STEP I1"
460 PRINT
470 PRINT "CONTROL VARIABLE:"
480 PRINT "SHOULD BE","ACTUAL","RESULT"
490 LET T1=0
500 FOR I1=I1 TO -20 STEP I1
510 LET T1=T1+1
520 GOSUB 3120
530 IF T1>20 THEN 580
540 LET I2=I2-3
550 NEXT I1
560 PRINT "LOOP EXITED"
570 GOTO 600
580 PRINT "JUMPED OUT OF LOOP: INCORRECT"
590 LET S1=1
600 GOSUB 3120
610 GOSUB 3000
700 LET I1=-2
710 LET I2=9
720 LET T2=6
730 PRINT
740 PRINT "I1 SET TO -2"
750 PRINT "LOOP IS: FOR I1=9 TO I1 STEP I1"
760 PRINT
770 PRINT "CONTROL VARIABLE:"
780 PRINT "SHOULD BE","ACTUAL","RESULT"
790 LET T1=0
800 FOR I1=9 TO I1 STEP I1
810 LET T1=T1+1
820 GOSUB 3120
830 IF T1>20 THEN 880
840 LET I2=I2-2
850 NEXT I1
860 PRINT "LOOP EXITED"
870 GOTO 900
880 PRINT "JUMPED OUT OF LOOP: INCORRECT"
890 LET S1=1
900 GOSUB 3120
910 GOSUB 3000
2000 IF S1=0 THEN 2030
2010 PRINT "*** TEST FAILED  ***"
2020 GOTO 2040
2030 PRINT "*** TEST PASSED ***"
2040 PRINT
2050 PRINT "               END TEST."
2060 PRINT
2070 PRINT "END PROGRAM 48"
2080 STOP
3000 REM SUBROUTINE TO CHECK NUMBER OF TIMES THROUGH LOOP
3010 LET M$="  OK  "
3020 IF T1=T2 THEN 3050
3030 LET M$="FAILED"
3040 LET S1=1
3050 PRINT
3060 PRINT "NO. TIMES THROUGH LOOP:"
3070 PRINT "SHOULD BE: ";T2;"     ACTUAL: ";T1;"   RESULT: ";M$
3080 PRINT
3090 PRINT "----------------------------"
3100 PRINT
3110 RETURN
3120 REM SUBROUTINE TO CHECK THAT I1=I2
3130 LET M$="  OK  "
3140 IF I1=I2 THEN 3170
3150 LET M$="FAILED"
3160 LET S1=1
3170 PRINT I2,I1,M$
3180 RETURN
3190 END
