IF-THEN-ELSIF-ELSE-END_IF statement
This section is about IF-THEN-ELSIF-ELSE-END-IF statement syntax and examples.
The ELSE and ELSIF statements are optional. If the ELSE statement is not written, no instruction is executed when the condition is FALSE.
You can use the ELSIF statement more than once. The ELSE statement, if used, must appear only once at the end of the "IF, ELSIF..." sequence.
Item | Description |
---|---|
Name | IF ... THEN ... ELSIF ... THEN ... ELSE ... END_IF |
Meaning | Executes one of several lists of structured text statements. A selection is made according to the value of a Boolean expression. |
Syntax |
|
Example
(* ST program using IF statement *) IF manual AND not (alarm) THEN level := manual_level; bx126 := bi12 OR bi45; ELSIF over_mode THEN level := max_level; ELSE level := (lv16 * 100) / scale; END_IF; (* IF structure without ELSE *) If overflow THEN alarm_level := true; END_IF;
Provide Feedback