Atari 130XE — 130XE Owners Manual_Page_068

Sometimes the delay loop is sandwiched on the same program line: NEW .10 FOR DELAV=.1 TO 300: NEXT DELAV LIST RUN Sample Programs The programs below use FOR-NEXT loops in a variety of ways. The first program uses the FOR-NEXT loop as a simple delay loop to leave the word H I on the screen long enough to be read before line 30 clears the screen: NEW .1 REM *** DLAVLOOP *** 5 PRINT " '" " .10 PRINT "HI" 20 FOR DELAV=.1 TO 800: NEXT DELAV 30 PRINT" "''' 40 PRINT" BVE" 50 FOR DELAV=.1 TO 800: NEXT DELAV T he next program uses a numeric variable in the FOR-NEXT loop. It also uses a TRAP command that refers the computer back to the previous line, giving no specific message about the error:

NEW .1 REM *** HOWHIGH? *** .10 DIM (.1) .. HH$(.1) 20 PRINT" '" " 30 PRINT: PRINT "HOW HIGH DO YOU WANT TO COUNT" ,: 40 TRAP 30 50 INPUT HH 55 HH$=STR$(HH): IF HH$="O" THEN GO TO 30 60 FOR COUNT=.1 TO HH 70 PRINT COUNT 80 NEXT COUNT ~O PRINT : PRINT" PLEASE ANSWER (V /N) , WOULD YOU LIKE TO .100 TRAP ~O COUNT AGAIN" ; .120 IF A$=" V" THEN GOTO 30 .130 IF A$=" N" THEN PRINT: PRINT" BVE" : END .1.10 INPUT .140 GOTO ~O The last program paraphrases an old rock 'n' roll song and uses "nested" FOR-NE XT loops. A nested FOR-NEXT loop is a sma ll er delay loop inside a la rg er FOR-NEXT loop. The program also uses OR to create multiple conditions in the I F-TH EN statement: 62