Attention

IronPLC can only run very simple programs. The steps described are accurate but many language features are not yet supported.

IF

The IF statement executes a block of statements conditionally based on boolean expressions.

IEC 61131-3

Section 3.3.2.3

Support

Supported

Syntax

IF expression THEN
    statement_list
{ ELSIF expression THEN
    statement_list }
[ ELSE
    statement_list ]
END_IF ;

The ELSIF and ELSE clauses are optional. Multiple ELSIF clauses may appear.

Description

The IF statement evaluates the boolean expression after IF. If it is TRUE, the corresponding statement list executes. Otherwise, each ELSIF expression is evaluated in order. If none are TRUE and an ELSE clause is present, its statement list executes.

Example

See Also

  • CASE — multi-way selection by integer value