Omron CX-PROGRAMMER V8.1 Operation Manual page 182

Function blocks/ structured text
Table of Contents

Advertisement

Statement Descriptions
■ Reserved Words
WHILE, DO, END_WHILE
■ Statement Syntax
WHILE <condition> DO
<expression>;
END_WHILE;
■ Processing Flow Chart
Iteration
Expression
■ Usage
Use the WHILE statement when the number of iterations has not been deter-
mined beforehand (depends on the condition being met) to repeat specified
processing for the duration that the condition is met. This statement can be
used to execute processing while the condition equation is true only (pretest
loop).
■ Description
Before the expression is executed, the condition is evaluated.
If the condition is true, the expression is executed. Afterwards, the condition is
evaluated again. This process is repeated. If the condition is false, the expres-
sion is not executed and the condition evaluation ends.
■ Precautions
• WHILE must be used in combination with END_WHILE.
• Before executing the expression, if the condition equation is false, the pro-
cess will end without executing the expression.
• Statements that can be used in the expression are assignment state-
ments, 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.
• The condition can also be specified as a boolean variable (BOOL data
type) only rather than an equation.
■ Examples
Example 1: The value exceeding 1000 in increments of 7 is calculated and
substituted for variable A.
A:=0;
WHILE A<=1000 DO
A:=A+7;
END_WHILE;
False
Condition
True
End
Section 5-5
157

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sysmac ws02-cxpc1-v8Sysmac cx-programmer 8.1

Table of Contents