Mitsubishi Electric MELSEC Q Series Programming Manual page 57

Structured text
Hide thumbs Also See for MELSEC Q Series:
Table of Contents

Advertisement

4 ST PROGRAM EXPRESSIONS
4 - 17
(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.
[Description example]
(a) When actual device and operator are used in Boolean expression
WHILE W100 < (W2-100) D0 (* While W100<(W2-100) is true
W100 : = W100 + 1;
END_WHILE;
(b) When function is used in Boolean expression
WHILE BOOL_TO_DINT(M0) < BOOL_TO_DINT(M1) D0
D4 : = D4 + 1;
END_WHILE;
Repeat
FALSE
conditional
expression
TRUE
Statement
(* processing is repeated.
(* During repeat processing, W100 is
(* incremented by 1
(* While BOOL_TO_DINT(M0) <
(* BOOL_TO_DINT(M1) is true
(* processing is repeated.
(* During repeat processing, D4 is
(* incremented by 1
*)
*)
*)
*)
*)
*)
*)
*)
*)
4 - 17

Advertisement

Table of Contents
loading

This manual is also suitable for:

Melsec l series

Table of Contents