Glossary · IF

What is IF statement?

The conditional in ST: IF ... THEN ... ELSIF ... ELSE ... END_IF. The most used statement in the language.

Branches are tested in order and only the first true one runs. It must be closed with END_IF, and forgetting that is a classic beginner error.

When the result is a single boolean, a direct assignment is clearer than a conditional: write Alarm := Level > 85.0; instead of IF Level > 85.0 THEN Alarm := TRUE; ELSE Alarm := FALSE; END_IF.

Related terms

CASE statement
A selection statement that runs one branch depending on an integer or enumerated value. It is what state machines in ST are built from.
Boolean expression
An expression whose result is TRUE or FALSE, built from comparisons and the operators AND, OR, XOR and NOT.

All terms