← All lessonsLESSON 38 lines
LESSON 3 OF 13
LOOPS
Doing something many times with FOR and NEXT.
FORNEXTSTEPnested loops
FOR I=1 TO 12 starts a loop with I set to 1. Everything up to the matching NEXT runs, then I becomes 2, and so on until I passes 12.
STEP changes the increment. STEP -2 counts down in twos. The loop variable is a normal variable, so you can use it in calculations and PRINT it.
A loop always runs at least once on a C64, even if the end is smaller than the start. That catches everyone out eventually.
Type with the keyboard under the screen, or tap the blue screen to use your phone's own keyboard. While a program runs, keys go to INPUT and GET. When it says READY., type a line and press RETURN to run it straight away.