Omron CX-PROGRAMMER 5.0-FUNCTION BLOCK OPERATION Operation Manual page 166

Function blocks
Table of Contents

Advertisement

Structured Text (ST Language) Specifications
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
SP[n]:=100;
END_FOR;
TO 50
BY 5 DO
Appendix B
151

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the CX-PROGRAMMER 5.0-FUNCTION BLOCK OPERATION and is the answer not in the manual?

This manual is also suitable for:

Cx-programmer 5.0Sysmac ws02-cxpc1-e-v50Cs1-hCj1-hCj1m

Table of Contents

Save PDF