151
Statement Descriptions Section 5-5
Note ELSE can be omitted.
Statement Syntax IF <condition_1> THEN <expression_1>;
ELSIF <condition_2> THEN <expression_2>;
ELSIF <condition_3> THEN <expression_3>;
...
ELSIF <condition_n> THEN <expression_n>;
ELSE <expression_m>;
END_IF;
Processing Flow Chart
■ Usage
Use the IF statement to perform different operations depending which of mul-
tiple conditions (condition equation) is met.
■ Description
Condition 1 = If true, execute expression 1
Condition 1 = If false,
Condition 2 = If true, execute expression 2
Condition 2 = If false,
Condition 3 = If true, execute expression 3
etc.
Condition n = If true, execute expression n
If none of these conditions are met, condition m is executed.
■ Precautions
• IF must be used together with END_IF.
• Condition_@ contains the true or false result of the equation (e.g.,
IF(A>10)).
A boolean (BOOL data type) variable only can also be specified as the
condition rather than an equation. For boolean conditions, the result is
true when the variable value is 1 (ON) and false when it is 0 (OFF).
• Statements that can be used in expression_@ are assignment state-
ments, IF, CASE, FOR, WHILE, or REPEAT.
Condition 1
Condition 2
Condition 3
False
False
False
Tr ue
Tr ue
Tr ue
Expression 1
Expression 2
Expression 3
Expression m