Mitsubishi Electric MELSEC Q Series Programming Manual page 80

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

Advertisement

FOR...DO syntax
■Format
FOR <Repeat variable initialization>
TO <Last value>
BY <Incremental expression> DO
<Syntax ...>;
END_FOR;
■Description
First, initialize the data to be used as an iteration variable.
One or more statements between the DO statement and the END_FOR statement are executed repeatedly, adding or
subtracting the initialized iteration variable according to the increase expression until the final value is exceeded.
The iteration variable after the FOR...DO statement is completed retains the value at the end of the processing.
■Example
FOR intV1 := 0
TO 30
BY 1 DO
intV3 := intV1 + 1;
END_FOR;
WHILE...DO syntax
■Format
WHILE <Boolean expression> DO
<Syntax ...>;
END_WHILE;
■Description
The WHILE...DO syntax executes one or more syntax while the value of Boolean expression (conditional expression) is
TRUE.
The Boolean expression is evaluated before the execution of the syntax. If the value of Boolean expression is FALSE, the
syntax within DO...END_WHILE is not executed. Since a return result of the Boolean expression in the WHILE syntax
requires only TRUE or FALSE, any Boolean expression that can be specified in the IF conditional syntax can be used.
■Example
WHILE intV1 = 30 DO
intV1 := intV1 + 1;
END_WHILE;
5 WRITING PROGRAMS
78
5.1 ST

Advertisement

Table of Contents
loading

This manual is also suitable for:

Melsec f seriesMelsec l series

Table of Contents