11 - 86 11 - 86
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
IF THEN ELSE
Instruction
IF to THEN toELSE
• Selects an instruction to execute according to the result of the expression.
IF <conditional expression> THEN <instruction> / <line number> [: <instruction> / <line
number> ] [ ELSE <instruction> / <line number>]
conditional expression
• • • •
Specify by a relational operation expression ( <, >,
=).
Syntax
instruction or line number
• • • •
Specify an instruction to execute or a line number to
branch after THEN or ELSE.
IF X=Y THEN PRINT “Hit!”
ELSE PRINT “Miss!”
• • • •
Displays “Hit!” if X and Y are the same, or displays
“Miss!” otherwise.
Examples
IF X=0 THEN 100 ELSE
200
• • • •
Executes line 100 if X is 0 or executes line 200
otherwise.
Description
• The IF to THEN to ELSE instruction selects an instruction to execute or a line number to
branch according to on the result of the expression.
• If the condition of <conditional expression> is true, the instructions after THEN are
executed. Instructions after ELSE are ignored.
• If the condition of <conditional expression> is false, the instructions after THEN are ignored
and instructions after ELSE are 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 another IF instruction after THEN or ELSE.
Example IF <conditional expression 1)> THEN IF <conditional expression 2)> THEN
Instruction 1) ELSE Instruction 2) ELSE ELSE Instruction 3 )
.
Instruction
3)
Conditional
expression
1)
Conditional
expression
2)
YES
YES
Instruction
1)
Instruction
2)
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...