EasyManua.ls Logo

Atari 65XE

Atari 65XE
135 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
NEW
10 FOR X=1 TO 4
20 PRINT "POTATO"
30 NEXT X
RUN
POTATO appears on the screen four times. Change line 10 to read like
this:
10 FOR X=1 TO 7
When you run the program this time, the screen shows POTATO seven
times. The computer is looping seven times through lines 10, 20, and
30. FOR tells the computer how many times to loop, and NEXT tells
the computer to go back to the top and start again. NEXT is similar to
GOTO. X is a variable. You can use anything to represent the variable.
Try this name for the variable:
10 FOR NUM=1 TO 7
30 NEXT NUM
When you run the program, there is no difference from the previous
program. Change the variable name again:
10 FOR JKL=1 TO 7
30 NEXT JKL
JKL is a nonsense name for the numeric variable in the FOR-NEXT
loop. Run the program to see that it, too, runs the same as before.
Now add this line:
15 PRINT JKL,
RUN
The PRINT statement in line 15 shows the value of the variable. (Put
the comma in for readability.) Each time the computer repeats the
FOR-NEXT loop, the variable takes on the value of the next number in
the series specified in line 10. The first time, the variable is 1; the
second time, 2; and so on. The last number in the FOR statement
controls the number of times the computer loops through the program.
Change that number in line 10 as shown below:
10 FOR JKL=1 TO 50
RUN
10 FOR JKL=1 TO 200
RUN
10 FOR JKL=1 TO 500
RUN
58

Related product manuals