10 PRINT "PROGRAM FILE 44: ELEMENTARY USE OF THE FOR-STATEMENT."
20 PRINT "    ANSI STANDARD 11.2, 11.4"
30 PRINT
40 PRINT "SECTION 44.1: ELEMENTARY USE OF THE FOR-STATEMENT."
50 PRINT
60 PRINT "THIS SECTION TESTS A SIMPLE FOR-NEXT CONSTRUCTION WITH"
70 PRINT "A VARIETY OF VALUES FOR THE INITIAL-VALUE, LIMIT, AND"
80 PRINT "INCREMENT. TO PASS THE TEST, THE CONTROL-VARIABLE MUST"
90 PRINT "TAKE ON THE APPROPRIATE VALUES AND THE LOOP MUST BE EXECUTED"
100 PRINT "THE CORRECT NUMBER OF TIMES."
110 PRINT
120 PRINT "               BEGIN TEST."
130 LET F=0
140 PRINT
150 LET A1=.0987789
160 LET B1=.09878
170 LET C1=3E-7
180 LET T2=4
190 GOSUB 3000
200 LET A1=5
210 LET B1=8
220 LET C1=-1
230 LET T2=0
240 GOSUB 3000
250 LET A1=8
260 LET B1=5
270 LET C1=1
280 LET T2=0
290 GOSUB 3000
300 LET A1=8
310 LET B1=-5
320 LET C1=-3
330 LET T2=5
340 GOSUB 3000
350 LET A1=-1.7
360 LET B1=2.6
370 LET C1=.27
380 LET T2=16
390 GOSUB 3000
400 LET A1=11
410 LET B1=-7
420 LET C1=-3
430 LET T2=7
440 GOSUB 3000
450 LET A1=2
460 LET B1=2
470 LET C1=20
480 LET T2=1
490 GOSUB 3000
500 LET A1=1.234E20
510 LET B1=-4.321E20
520 LET C1=-8.7E19
530 LET T2=7
540 GOSUB 3000
550 LET A1=0
560 LET B1=0
570 LET C1=-2
580 LET T2=1
590 GOSUB 3000
2000 PRINT
2010 IF F=0 THEN 2040
2020 PRINT "*** TEST FAILED IN ";F;" CASE(S) ***"
2030 GOTO 2050
2040 PRINT "*** TEST PASSED ***"
2050 PRINT
2060 PRINT "               END TEST."
2070 PRINT
2080 PRINT "END PROGRAM 44"
2090 STOP
3000 REM SUBROUTINE TO TEST VARIOUS VALUES IN THE FOR-LOOP
3010 PRINT
3020 PRINT "LOOP IS: FOR I1=";A1;" TO ";B1;" STEP ";C1
3030 PRINT
3040 PRINT "CONTROL VARIABLE:"
3050 PRINT "SHOULD BE","ACTUAL","RESULT"
3060 LET A2=A1
3070 LET B2=B1
3080 LET C2=C1
3090 LET I2=A2
3100 REM S1 IS ERROR SWITCH
3110 LET S1=0
3120 REM T1 IS LOOP COUNT
3130 LET T1=0
3140 FOR I1=A1 TO B1 STEP C1
3150 LET T1=T1+1
3160 LET M$="  OK  "
3170 IF I1=0 THEN 3220
3180 LET R=(I2-I1)/I1
3190 IF R<-1E-6 THEN 3230
3200 IF R>1E-6 THEN 3230
3210 GOTO 3250
3220 IF I2=0 THEN 3250
3230 LET M$="FAILED"
3240 LET S1=1
3250 PRINT I2,I1,M$
3260 LET I2=I2+C2
3270 NEXT I1
3280 PRINT "LOOP EXITED"
3290 LET M$="  OK  "
3300 IF I1=0 THEN 3350
3310 LET R=(I2-I1)/I1
3320 IF R<-1E-6 THEN 3360
3330 IF R>1E-6 THEN 3360
3340 GOTO 3380
3350 IF I2=0 THEN 3380
3360 LET M$="FAILED"
3370 LET S1=1
3380 PRINT I2,I1,M$
3390 LET M$="  OK  "
3400 IF T1=T2 THEN 3425
3410 LET M$="FAILED"
3420 LET S1=1
3425 PRINT
3430 PRINT "NO. TIMES THROUGH LOOP:"
3440 PRINT "SHOULD BE: ";T2;"     ACTUAL: ";T1;"   RESULT: ";M$
3450 PRINT
3455 PRINT "-----------------------------------------------"
3460 LET F=F+S1
3470 RETURN
3480 END
