3 - 27 3 - 27
MELSEC-Q
3 LET'S CREATE AND EXECUTE A PROGRAM
3.7.2 Judgment instructions
Use the IF instruction to make a judgment. The IF instruction is entered in the format
shown below.
IF
Condition or
logical expression
THEN
Instruction
executed when the
condition or logical
expression is met
ELSE
Instruction
executed when the
condition or logical
expression is not
met
(1) Specify the condition or logical expression in [Condition or logical expression]
according to the method shown in Section 3.7.1.
(2) Enter the instruction to be executed when [Condition or logical expression] is met
after the THEN instruction. Any instructions can be entered, and it is possible to
use multi-statements ( Section 2.3).
(3) Enter the instruction to be executed when [Condition or logical expression] is not
met after the ELSE instruction. As with (2), any instructions can be entered, and
multi-statements ( Section 2.3) are allowed.
Example
10 FOR I=1 TO 10
20 IF I<=5 THEN PRINT I; "Less than or equal to"
ELSE PRINT I; " G r e a t e r t h a n "
30 NEXT I
40 END
RUN
1 Less than or equal to.
2 Less than or equal to.
5 Less than or equal to.
6 Greater than
10 Greater than
OK
It is not necessary
to split line 20 as
shown here.
You can enter it
in one line.
…
…
…… Executed when I is less than 5
Executed when I is greater tha n
………… ……
REMARK
When the GOTO instruction is placed after the THEN or ELSE instruction, the
GOTO or THEN instruction can be omitted as shown below.
Example
IF A=1 THEN GOTO 100 ELSE GOTO 200
IF A=1 THEN 100 ELSE 200
IF A=1 THEN GOTO 70 ELSE GOTO 10
IF A=1 GOTO 70 ELSE 10
ELSE cannot be omitted.
Содержание 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...