Chapter 2 Syntax
for-next loop statements
for loop instruction
- Format
Format
Description
for
<variable> <start value> <end value>
<incremental value>
<instruction set>
next
This loop instruction executes
<instruction set>
repeatedly until
<variable>
exceeds
<end value>
.
Note that
<variable>
, which initially contains
<start value>
, is
incremented by
<incremental value>
each time
<instruction
set>
is executed.
- Explanation
Use the for loop statement to effectively describe a process for which the number of execution times is predetermined.
As a loop process,
<instruction set>
is executed and
<variable>
incremented by
<incremental value>
from
<start value>
.
If
<variable>
exceeds
<end value>
, processing exits the loop. Otherwise, the loop process is repeated. Therefore,
<instruction set>
is always executed at least once.
The following chart shows the flow of processing.
Assign
<start value>
in
<variable>
Execute
<instruction set>
Assign “
<start value>
+
<incremental value>
” to
<variable>
Did
<variable>
exceed
<end value>
?
No
Yes
<variable>
:
Specifies the name of the variable to be used for the loop.
<start value>
:
Specifies the initial value of
<variable>
to be applied at the beginning of the loop. You can specify a
variable name or immediate value (i.e., a value that can be entered directly). The immediate value must
be an integer ranging from 0 to 127. To use a larger numerical value, preset the value in a variable and
specify the variable as
<start value>
.
<end value>
:
Specifies the limit value at which to exit the loop. Processing exits the loop when
<variable>
exceeds
<end value>
. You can specify a variable name or immediate value (i.e., a value that can be entered
directly). The immediate value must be an integer ranging from 0 to 127. To use a larger numerical
value, preset the value in a variable and specify the variable as
<end value>
.
<incremental value>
: Specifies the value to be added to
<variable>
each time the loop is executed. You can specify a
variable name or immediate value (i.e., a value that can be entered directly). The immediate value must
be an integer ranging from 0 to 127. To use a larger numerical value, preset the value in a variable and
specify the variable as
<incremental value>
.
<instruction set>
: Describes the set of instructions to be executed in one loop process. The instructions may be
described on two or more lines. The instructions are executed in units of lines in a cycle as explained
below.
2-11
Summary of Contents for NT2021XA
Page 4: ... Safety Instructions ...
Page 8: ... Contents ...
Page 10: ...Chapter 1 Outline of EzSQ ...
Page 14: ...1 4 Chapter 1 Outline of EzSQ ...
Page 16: ...Chapter 2 Syntax ...
Page 68: ...2 52 Chapter 2 Syntax ...
Page 70: ...Chapter 3 Interface with the Inverter ...
Page 80: ...3 10 Chapter 3 Interface with the Inverter ...