157
Statement Descriptions
Section 5-5
■
Reserved Words
WHILE, DO, END_WHILE
■
Statement Syntax
WHILE
<
condition
>
DO
<
expression
>
;
END_WHILE;
■
Processing Flow Chart
■
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;
Iteration
Condition
Expression
False
True
End
Summary of Contents for SYSMAC CX-Programmer 9
Page 2: ......
Page 4: ...iv ...
Page 6: ...vi ...
Page 8: ......
Page 16: ...xvi ...
Page 20: ...xx ...
Page 26: ...xxvi Application Precautions 4 ...
Page 27: ...Part 1 Function Blocks ...
Page 28: ......
Page 154: ...128 Procedures Section 3 2 ...
Page 155: ...Part 2 Structured Text ST ...
Page 156: ......
Page 160: ...134 CX Programmer Specifications Section 4 2 ...
Page 206: ...180 Procedures Section 6 1 ...
Page 208: ...182 System defined external variables supported in function blocks Appendix A ...
Page 230: ...204 Revision History ...
Page 231: ......