4 - 17 4 - 17
4 ST PROGRAM EXPRESSIONS
(2) WHILE...DO syntax
[Format]
WHILE <Boolean expression> D0
<Statement ...>
END_WHILE;
[Explanation]
The WHILE ... DO syntax executes one or more statements while the
Boolean expression (conditional expression) is TRUE.
The Boolean expression is judged before execution of the statement. If the
Boolean expression is FALSE, the statement in DO ... END_WHILE is not
executed. Since the <Boolean expression> in the WHILE syntax is only
required to return whether the result is true or false, all expressions that can
be specified in the <Boolean expression> in the IF conditional statement
can be used.
TRUE
FALSE
Statement
Repeat
conditional
expression
[Description example]
(a) When actual device and operator are used in Boolean expression
WHILE W100 < (W2-100) D0 (* While W100<(W2-100) is true
*)
(* processing is repeated.
*)
W100 : = W100 + 1;
(* During repeat processing, W100 is
*)
(* incremented by 1
*)
END_WHILE;
(b) When function is used in Boolean expression
WHILE BOOL_TO_DINT(M0) < BOOL_TO_DINT(M1) D0
D4 : = D4 + 1;
(* While BOOL_TO_DINT(M0) <
*)
(* BOOL_TO_DINT(M1) is true
*)
(* processing is repeated.
*)
(* During repeat processing, D4 is
*)
(* incremented by 1
*)
END_WHILE;
Содержание MELSEC L series
Страница 1: ...Programming Manual Structured Text ...
Страница 2: ......
Страница 73: ...4 33 4 33 4 ST PROGRAM EXPRESSIONS MEMO ...
Страница 297: ......