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.

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.

LD Language

Not available.

Fixed_Image See also

WHILE  REPEAT  FOR  CASE  EXIT

IF THEN ELSE ELSIF END_IF

IEC 61131-3 Automation platform > Programming - Reference guide > Basic Operations > IF THEN ELSE ELSIF END_IF

Previous chapterNext chapter


Created with the Personal Edition of HelpNDoc: Transform Your Documentation Workflow with HelpNDoc's Intuitive UI