Loop While A Certain Condition Is Met - Mitsubishi QD51 Programming Manual

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

Advertisement

3 LET'S CREATE AND EXECUTE A PROGRAM

3.6.4 Loop while a certain condition is met

3 - 25
Use the WHILE-WEND instructions to repeat execution of instructions only while a
certain condition is met.
This is a condition that is true as long as N is less than 4.
10 N=0
20 WHILE N<4
30 PRINT N;
40 N=N+1
50 WEND
Instructions in this range are repeated.
60 END
The instructions in the loop are repeated while the condition stated immediately after
WHILE is met.
For details on how to specify conditional expressions, see Section 3.7.
The WHILE-WEND instructions are loop instructions very similar to the FOR-NEXT
instructions, but it is the WHILE instruction that determines whether or not the loop
should continue. Therefore, if a condition is not met from the beginning, the instructions
between the WHILE and the WEND will not be executed even once.
FOR-NEXT loop
10 FOR N=1 TO 1
20 PRINT N
30 NEXT N
40 END
RUN
1
OK
The NEXT instruction determines
whether the loop should continue.
RUN
0 1 2 3
OK
WHILE-WEND loop
10 N=1
20 WHILE N<1
30 PRINT N
40 WEND
50 END
RUN
1
OK
MELSEC-Q
3 - 25

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents