11 - 84 11 - 84
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
IF GOTO ELSE
Instruction
IF to GOTO to ELSE
• Selects a branch destination according to the result of an expression.
IF <conditional expression> GOTO <line number> [ ELSE <instruction> / <line
number> ]
conditional expression
• • • •
Specify with a relational operation expression (<, >,
=).
line number
• • • •
Specify a line number of execution destination that is
executed when the conditional expression is true.
Syntax
instruction/line number
• • • •
Specify the instruction that is executed when the
conditional expression is false, or a line number of
execution destination.
IF X> Y GOTO 100 ELSE
END
• • • •
Branches to line 100 when X is greater than Y.
Otherwise, terminates the program execution.
Examples
IF X=0 GOTO 100 ELSE
200
• • • •
Branches to line 100 if X is 0. If X is not 0, branches
to line 200.
Description
• The IF to GOTO to ELSE instruction selects the execution according to the result of the
expression.
• If the condition of <conditional expression> is true, the instruction after GOTO is executed
and the instruction after ELSE is ignored.
• If the condition of <conditional expression> is false, the instruction after GOTO is ignored
and the instruction after ELSE is executed.
The execution moves to the instruction of the next line if ELSE is not specified.
• <line number> can also be specified by a label.
• The IF instruction can be nested by writing a separate IF instruction after ELSE.
Example IF <conditional expression 1)> GOTO 100 100 ELSE IF <conditional
expression 2)> GOTO 200 ELSE 300
Line 100
Conditional
expression
1)
Conditional
expression
2)
YES
YES
Line 200
Line 300
NO
NO
Содержание 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...