Loops
"Loops" make it easier to do an action multiple times. There are at least four types of loops:
IF...GOTO, WHILE...WEND, DO...LOOP, and FOR...NEXT.
IF...GOTO
This program uses IF...GOTO to create a loop:
x = 10
start:PRINT x
x = x + 1 (This adds 1 to x)
IF x < 15 THEN GOTO start
Output:
10
(^1112)
13
14
WHILE...WEND
The WHILE...WEND commands continue a loop until a specified expression is false.
To use WHILE...WEND:
- Place an expression after WHILE
- Enter a list of commands
- Place WEND at the end
Run the following:
x = 10
WHILE x < 15
PRINT x
x = x + 1
WEND