IF  THEN  ELSE  ELSIF  END_IF

Statement - Conditional execution of statements.

Syntax

IF <BOOL expression> THEN
<statements>
ELSIF <BOOL expression> THEN
<statements>
ELSE
<statements>
END_IF;

Remarks

  • The IF statement is available in ST only.
  • The execution of the statements is conditioned by a Boolean expression.
  • ELSIF and ELSE statements are optional.
  • There can be several ELSIF statements.

FBD Language Example

Not available.

FFLD Language Example

Not available.

IL Language Example

Not available.

ST Language Example

(* simple condition *)
            
IF bCond THEN
Q1 := IN1;
Q2 := TRUE;
END_IF;

(* binary selection *)
IF bCond THEN
Q1 := IN1;
Q2 := TRUE;
ELSE
Q1 := IN2;
Q2 := FALSE;
END_IF;

(* enumerated conditions *)
IF bCond1 THEN
Q1 := IN1;
ELSIF bCond2 THEN
Q1 := IN2;
ELSIF bCond3 THEN
Q1 := IN3;
ELSE
Q1 := IN4;
END_IF;

See Also