Atari 130XE — 130XE Owners Manual_Page_064

NEW 1.9 FOR K=1. TO 4 29 PRINT "POTATO" 39 NEKT K RUN POTATO appears on the screen four times. Change line 10 to read like this: 1.9 FOR K=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 th e 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: 1.9 FOR NUH=1. TO 7 39 NEKT NUH When you run the program, there is no difference from the previous program. Change the variable name again: 1.9 FOR JKL=1.

TO 7 39 NEKT 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 lin e: 1.5 PRINT JKL .. RUN The PRINT statement in line 15 shows the va lue 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 ne xt number in the series specified in line 10. The first time, the variable is 1; th e 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: 1.9 FOR JKL=1. TO 59 1.9 FOR JKL=1.

TO 299 RUN RUN 1.0 FOR JKL=1. TO 509 RUN 58