For To Next ( Executes A Series Of Instructions For The Specified Number Of Times ) - Mitsubishi QD51 Programming Manual

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

11 INSTRUCTIONS AND FUNCTIONS
FOR to NEXT
• Executes a series of instructions for the specified number of times.
FOR
Syntax
NEXT [ <variable name> ] [, <variable name> ]
variable name
initial value
final value
increment
FOR I=0 TO 100 STEP 2
Examples
to
NEXT I
• The FOR to NEXT instruction repeatedly executes the instructions between FOR and
Description
NEXT for the specified number of times.
• Only an integer variable and single precision variable can be used for the variable specified
by <variable name>. Character variable and double precision variable cannot be used.
• When instructions between the FOR instruction and the NEXT instruction are executed, an
increment specified by STEP is added to the variable and compared to the final value.
If the value of the variable is equal to or less than the final value, the same processing is
repeated after returning to the instruction following the FOR instruction. If the value of the
variable is larger than the final value, the instruction after the NEXT instruction will be
executed.
• The increment of the variable is considered 1 if STEP is omitted.
If the value specified by STEP is negative, the final value must be smaller than the initial
value. In this case, the variable decrements after every repeat and it continues until the
value of the variable is less than the final value.
If the STEP value is positive and the initial value is larger than the final value, or if the
STEP value is negative and the initial value is smaller than the final value, the instructions
between the FOR instruction and the NEXT instruction is executed only once.
• The FOR to NEXT loop can be nested. A FOR to NEXT loop can be inside of another FOR
to NEXT loop.
If the loop is nested, the variable used in each loop has to be distinct. A FOR to NEXT
instruction loop has to be within another FOR to NEXT instruction.
FOR I=0 TO 10
FOR J=0 TO 10
to
NEXT J
NEXT I
11 - 70
Instruction
<variable name> = <initial value>
Repeat
FOR to NEXT
TO <final value>
• • • •
Specify a variable that controls the repeat.
• • • •
Specify the initial value of the variable that controls
the repeat.
• • • •
Specify the final value of the variable that controls
the repeat.
• • • •
Specify the increment of the variable that controls
the repeat.
Repeatedly executes through NEXT I by changing
• • • •
variable I from 0 to 100 with increment 2.
Repeat
MELSEC-Q
[STEP <increment> ]
11 - 70

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents