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 STClosed"Structured text" A high-level language that is block structured and syntactically resembles Pascal only. The execution of the statements is conditioned by a Boolean expression. ELSIF and ELSE statements are optional. There can be several ELSIF statements.

ST Language

(* 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;

FBD Language

Not available

FFLD Language

Not available

IL Language

Not available

See also

WHILE   REPEAT   FOR   CASE    EXIT