
11-12
FOR-NEXT (Statement) [Conforms to SLIM]
Function
Repeatedly executes a series of instructions between FOR-NEXT sections.
Format
FOR <Variable name> = <Initial value> TO <Final value> [STEP <Increment>]
:
NEXT [<Variable name>]
Explanation
This statement repeatedly executes a series of instructions between FOR-
NEXT according to the condition designated on the FOR line.
Set the initial value of the variable designated by <Variable name> for <Initial
value>.
Set the final value of the variable designated by <Variable name> for <Final
value>.
Set an increment value between the initial value and the final value for
<Increment>. The increment is regarded as 1 if STEP is ignored.
In the following cases, FOR-NEXT is not executed and execution proceeds to
the next statement of NEXT.
(1) If <Increment> is a positive value and <Initial value> is larger than <Final
value>
(2) If <Increment> is a negative value and <Initial value> is smaller than
<Final value>.
However, <Initial value> is assigned to <Variable>.
You can put another FOR-NEXT in one FOR-NEXT (referred to as a nested
construction).
In this case, a different variable must be used for each <Variable name>.
Additionally, one FOR-NEXT must be completely inside the other FOR-NEXT.
Note : FOR and NEXT must be a pair.
If a program jumps into a FOR-NEXT loop or jumps out of the
loop, its operation is not guaranteed. If the increment is set
to 0, the loop becomes infinite.
Related Terms
DO-LOOP, EXIT FOR
Commentaires sur ces manuels