Repeat Statement - Mitsubishi MELSEC-q Programming Manual

Melsec q series; melsec l series
Hide thumbs Also See for MELSEC-q:
Table of Contents

Advertisement

4 ST PROGRAM EXPRESSIONS

4.3.3 Repeat statement

4 - 15
(1) FOR...DO syntax
[Format]
FOR <Repeat variable initialization>
TO <Last value expression>
BY <Incremental expression> DO
< Statement ...>
END_FOR;
Repeat variable initialization: The data used as a repeat variable is initialized.
Last value expression, incremental expression:
Data types that can be used in <Last value expression, incremental
expression> of FOR syntax
Integer values and the integer values of operation expression results can be
specified.
[Explanation]
The FOR ... DO syntax repeatedly executes several statements according
to the value of the repeat variable.
Precaution for use of repeat variable
The double precision integer type (DINT) and integer type (INT) can be used for
a repeat variable, but structure elements and array elements cannot be used.
Also, match the type used for the repeat variable with the types of the <last
value expression> and <incremental expression>.
Precaution for use of incremental expression
The <incremental expression> can be omitted. When omitted, the <incremental
expression> is executed as 1.
When "0" is assigned to the <incremental expression>, the FOR syntax and
later may not be executed or an endless loop may occur.
Precaution for use of FOR ... DO syntax
In the FOR ... DO syntax, the count processing of the repeat variable is
performed after execution of <Statement ...> in the FOR syntax. An endless
loop will occur if the count processing higher than the maximum value or lower
than the minimum value of the data type of the repeat variable is executed.
The initialized repeat variable is incremented or
decremented according to the incremental
expression, and repetitive processing is performed
until the last value is reached.
4 - 15

Advertisement

Table of Contents
loading

This manual is also suitable for:

Melsec-l

Table of Contents