155
Statement Descriptions
Section 5-5
■
Processing Flow Chart
■
Usage
Use the FOR statement when the number of iterations has been determined
beforehand. FOR is particularly useful when switching the number of ele-
ments in an array variable according to the value of a specified iteration vari-
able.
■
Description
When the
iteration_variable
is the
initial_value
, the
expression
is executed.
After execution, the value obtained from the
increment_equation
is added to
the
iteration_variable
, and if the
iteration_variable
<
final_value_equation
(see
note 1), the
expression
is executed. After execution, the value obtained from
the
increment_equation
is added to the
iteration_variable
, and if the
iteration_variable
<
final_value_equation
value (see note 1), the
expression
is
executed. This process is repeated.
If the
iteration_variable
≥
final_value_equation
(see note 2), the processing
ends.
Note
(1) If the value from the
increment_equation
is negative, the condition is
iteration_variable
>
final_value_equation
value.
(2) If the value from the
increment_equation
is negative, the condition is
iteration_variable
≤
final_value_equation.
■
Precautions
• A negative value can be specified in the
increment_equation
• FOR must be used in combination with END_FOR.
• The
initial_value
,
final_value_equation
, and
final_value_equation
must be
an integer data type (INT, DINT, LINT, UINT, UDINT, or ULINT).
• After processing is executed with the final value, the iteration value is
incremented to the final value + 1 and iteration processing ends.
Example: In the following structured text, the value of “
a”
becomes TRUE.
Iteration variable = Initial
True
False
Expression
End
Iteration
Iteration va Increment value
Iteration
variable
≥
Final value?
Summary of Contents for CX-PROGRAMMER V8.1
Page 3: ...iv...
Page 5: ...vi...
Page 7: ......
Page 15: ...xvi...
Page 19: ...xx...
Page 25: ...xxvi Application Precautions 4...
Page 26: ...Part 1 Function Blocks...
Page 27: ......
Page 153: ...128 Procedures Section 3 2...
Page 154: ...Part 2 Structured Text ST...
Page 155: ......
Page 159: ...134 CX Programmer Specifications Section 4 2...
Page 205: ...180 Procedures Section 6 1...
Page 207: ...182 System defined external variables supported in function blocks Appendix A...
Page 229: ...204 Revision History...
Page 230: ......