2 Instruction Descriptions
2-26
NJ-series Instructions Reference Manual (W502)
You can use ELSIF more than once. The following processing flow is for this example.
IF condition expression 1 THEN
statement 1;
ELSIF condition expression 2 THEN
statement 2;
ELSIF condition expression 3 THEN
statement 3;
ELSE
statement 4;
END_IF;
• You do not use ELSIF if there is only one condition expression. You do not use ELSE if no processing
is performed when none of the condition expressions are TRUE. The following processing flow is for
this example.
IF condition expression THEN
statement;
END_IF;
• There are no restrictions on the statements that you can use. You can use the same types of state-
ments for the statements in the IF construct as you do for the statements outside the IF construct. For
example, you can use function block calls and FOR constructs.
• You must always use IF and END_IF. They must be paired.
• You can use a hierarchy that is 15 levels deep, but count all levels of IF, CASE, FOR, WHILE, and
REPEAT constructs.
Precautions for Correct Use
FALSE
TRUE
FALSE
TRUE
FALSE
TRUE
Condition
expression 1
Statement 1
Statement 3 Statement 4
Statement 2
Condition
expression 2
Condition
expression 3
FALSE
TRUE
Statement
Condition
expression