If Then Else ( Selects An Instruction According To The Result Of The Expression ) - Mitsubishi QD51 Programming Manual

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

Advertisement

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

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents