Sample Programs - Atari 65XE Owner's Manual

Hide thumbs Also See for 65XE:
Table of Contents

Advertisement

Sometimes the delay loop is sandwiched on the same program line:
NEW
10 FOR DELAY=1 TO 300:NEXT DELAY
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 HI on the screen long enough to be read before line 30
clears the screen:
NEW
1 REM *** DLAYLOOP ***
5 PRINT " "
10 PRINT "HI"
20 FOR DELAY=1 TO 800:NEXT DELAY
30 PRINT " "
40 PRINT "BYE"
50 FOR DELAY=1 TO 800 : NEXT DELAY
The 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 A$ (1), HH$(1)
20 PRINT "
"
30 PRINT:PRINT "HOW HIGH DO YOU W A N T TO COUNT";
40 TRAP 30
50 INPUT HH
55 HH$=STR$(HH) : IF HH$="0" THEN GOTO 30
60 FOR COUNT = 1 TO HH
70 PRINT COUNT
80 NEXT COUNT
90 PRINT :PRINT "PLEASE A N S W E R (Y/N) . WOULD YOU LIKE TO
COUNT AGAIN";
100 TRAP 90
110 INPUT A$
120 IF A$="Y" THEN GOTO 30
130 IF A $ = " N " THEN PRINT:PRINT "BYE":END
140 GOTO 90
The last program paraphrases an old rock 'n' roll song and uses
"nested" FOR-NEXT loops. A nested FOR-NEXT loop is a smaller
delay loop inside a larger FOR-NEXT loop. The program also uses OR
to create multiple conditions in the IF-THEN statement:
62

Advertisement

Table of Contents
loading

Table of Contents