![background image](http://html1.mh-extra.com/html/omron/cs1-h-series/cs1-h-series_operation-manual_742526166.webp)
151
Structured Text (ST Language) Specifications
Appendix B
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).
• Do not reference an iteration variable that is outside the FOR statement, where possible. The value of the
iteration variable after completing execution of the FOR statement depends on the actual model specifica-
tions, and may prevent use of the program for general-purpose applications.
Example: In the following structured text, whether the value of
a
is TRUE or FALSE depends on the actual
model being used.
FOR i:=0 TO 100 DO
array[i]:=0;
END_FOR;
IF i=101 THEN
a:=TRUE;
ELSE
a:=FALSE;
END_IF;
• Do not use a FOR statement in which an iteration variable is changed directly. Doing so may result in unex-
pected operations.
Example:
FOR i:=0 TO 100 BY 1 DO
array[i]:=0;
i:=i+5;
END_FOR;
• Statements that can be used in the
expression
are assignment statements, IF, CASE, FOR, WHILE, or
REPEAT.
• Multiple statements can be executed in the
expression.
Be sure to use a semicolon (;) delimiter between
multiple statements in an
expression
.
• BY
increment_equation
can be omitted. When omitted, BY is taken as 1.
• Variables with integer data types (INT, DINT, LINT, UINT, UDINT, or ULINT), or equations that return inte-
ger values can be specified in the
initial_value, final_value_equation,
and
increment_equation.
Example 1: The iteration is performed when the iteration variable n = 0 to 50 in increments of 5, and the
array variable SP[n] is substituted with 100.
FOR n:=0 TO 50 BY 5 DO
SP[n]:=100;
END_FOR;
Содержание CS1-H Series
Страница 3: ...iv...
Страница 5: ...vi...
Страница 7: ...viii TABLE OF CONTENTS...
Страница 15: ...xvi Application Precautions 4...
Страница 151: ...136 Procedures Section 3 2...
Страница 153: ...138 Data Types Appendix A...
Страница 177: ...162 External Variables Appendix C...
Страница 181: ...166 Revision History...