IF-THEN-ELSIF-ELSE-END_IF Statement

The ELSE and ELSIF statements are optional. If the ELSE statement is not written, no instruction is executed when the condition is FALSE. The ELSIF statement can be used more than once. The ELSE statement, if used, must appear only once at the end of the ‘IF, ELSIF...’ sequence.
Name
IF ... THEN ... ELSIF ... THEN ... ELSE ... END_IF
Meaning
Executes one of several lists of Structured Text (ST) statements; selection is made according to the value of a Boolean expression
Syntax
IF <Boolean_expression> THEN <statement> ; <statement> ; ... ELSIF <Boolean_expression> THEN <statement> ; <statement> ; ... ELSE <statement> ; <statement> ; ... END_IF;
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; To insert an IF-THEN-ELSIF-ELSE-END_IF END_IF;
To insert an IF-THEN-ELSIF-ELSE-END_IF
  • From the
    Toolbox
    , drag the
    IF THEN ELSE
    element into the language container.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal