The IF - ELSE branch
The following control statements are used for IF-ELSE branches:
$IF, $ELSE, $ELSEIF, $ENDIF.
Syntax: |
Branching always starts with
$IF=.. |
and always ends with
$ENDIF |
Control statements
$ELSE |
and |
$ELSEIF |
are optional and serve to set up multiple branches.
Notice | |
The condition in the $IF control block is checked by verifying the mathematical expression for "true” or "not true” (TRUE and FALSE). To be able to also use decimal variables, the jump condition is regarded as fulfilled (TRUE) if... ...the absolute value of the mathematical expression is > or = 0.5. |
Programming Example
The IF - ELSE branch
statements N30 to N50 executed.
However, the following is also possible:
or:
N30 to N50 executed, otherwise N70 to N90
These use of ELSEIF permits:
to N50 executed, otherwise a check is made in the
$ELSEIF condition whether P2 is >= 0.5 and
accordingly N70 to N90 or N110 to N130 are executed.
nested branches.
Notice | |
The C programming language also makes a distinction in syntax between Assignment: P5 = 3 and Comparison: $IF P5 == 3 The following applies to Version 2.3 and earlier: As mathematical expressions expect always the sequence… Operator -> Term -> Operator -> Term -> etc. …expressions preceded by a minus sign must be bracketed in comparison operation ("-" is interpreted as operator). |