basic.next Statement/BASIC Program

basic.next

Command basic.next Statement/BASIC Program
Applicable release versions: AP, R83
Category BASIC Program (486)
Description occurs at the end of a "for..next" construct and causes the iteration counter to increment and branches to the corresponding "for" statement to decide whether to terminate.

The "for..next" construct may also be exited using the "exit" statement.

The "step" statement allows the increments of the loop to be changed. For example, "step 2" increments the variable by 2 when the "next" statement is encountered.

"step" can be a negative number, decrementing the variable at the "next" statement. A "step" of zero does not execute the "for..next" loop.
Syntax for variable = expression to expression {step expression}
statement{s}
next variable
Options
Example
for i = 1 to 10
 crt i:" ":
next i
print

1 2 3 4 5 6 7 8 9 10


numbers = ''
for i = 1 to 2
 for j = 1 to 5
   numbers<i,j> = j
 next j
next i
print numbers

1]2]3]4]5^1]2]3]4]5

for j = 10 to 1 step -1
 print j:" ":
next j
print

10 9 8 7 6 5 4 3 2 1
Purpose
Related basic.statements
basic.for.next
basic.exit