Selection Statements
SemanticsSelection statements include the IF and CASE statements. A selection statement selects one (or a group) of its component statements for execution based on a specified condition.
- IF: the IF statement specifies that a group of statements is to be executed only if the associated Boolean expression evaluates to the value TRUE. If the condition is false, then either no statement is to be executed, or the statement group following the ELSE keyword (or the ELSIF keyword if its associated Boolean condition is true) is executed.
- CASE: the CASE statement consists of an expression which evaluates to a variable of type DINT (the “selector”), and a list of statement groups, each group being labelled by one or more integer or ranges of integer values, as applicable. It specifies that the first group of statements, one of whose ranges contains the computed value of the selector, is to be executed. If the value of the selector does not occur in a range of any case, the statement sequence following the keyword ELSE (if it occurs in the CASE statement) is executed. Otherwise, none of the statement sequences is executed.
- IF:
- CASE: