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
Содержание SYSMAC CX-Programmer 9
Страница 2: ......
Страница 4: ...iv ...
Страница 6: ...vi ...
Страница 8: ......
Страница 16: ...xvi ...
Страница 20: ...xx ...
Страница 26: ...xxvi Application Precautions 4 ...
Страница 27: ...Part 1 Function Blocks ...
Страница 28: ......
Страница 154: ...128 Procedures Section 3 2 ...
Страница 155: ...Part 2 Structured Text ST ...
Страница 156: ......
Страница 160: ...134 CX Programmer Specifications Section 4 2 ...
Страница 206: ...180 Procedures Section 6 1 ...
Страница 208: ...182 System defined external variables supported in function blocks Appendix A ...
Страница 230: ...204 Revision History ...
Страница 231: ......