11 - 400 11 - 400
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
WHILE WEND
Instruction
WHILE to While END
• These instructions are used to execute the group of instructions between WHILE and
WEND repeatedly, while the specified condition holds.
Syntax
WHILE <expression>
WEND
expression
• • • •
Specify the condition under which the instructions
enclosed by the WHILE to WEND instructions are
executed repeatedly.
Examples
WHILE K>5
to
WEND
• • • •
Repeats the instructions between the WHILE to
WEND instructions as long as the value of K is
greater than 5.
Description
• The WHILE to WEND instructions are used to execute a selected processing under a
given condition. The group of instructions from the WHILE instruction to the WEND
instruction are executed repeatedly while the condition specified in <expression> holds.
• A pair of WHILE and WEND instructions constitute one loop together.
The difference from the FOR to NEXT instructions is instead of specifying the number of
repetitions of the execution, a condition for repeated execution is specified.
• If the value of <expression> is True (any other value than 0), the instructions from the one
immediately after the WHILE until the WEND instruction are executed and then the
execution returns to the WHILE instruction to evaluate <expression> again. This routine is
repeated while the value of <expression> is True. If the value of <expression> is False (0),
the instruction immediately after the WEND instruction is executed.
• The repeated processing between the WHILE to WEND instructions is stopped if a GOTO
or RESUME instruction is executed inside the WHILE to WEND loop in an error handling
routine.
• Lines where WHILE or WEND instructions are written can be specified as the branch
destination of a GOTO instruction, etc.
• It is possible to write the WHILE to WEND instructions within a loop created by another pair
of WHILE-WEND instructions.
• When using more than one pair of WHILE to WEND instructions, take precautions so that
the inner WHILE to WEND loop is completely contained within the outer loop.
WHILE
WEND
WEND
WHILE
:
WHILE
WEND
WEND
WHILE
:
(Incorrect)
(Correct)
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...