The IF - ELSE - branching

For IF-ELSE-branching, the following control statements are used:

$IF, $ELSE, $ELSIF, $ENDIF.

The branching always begins with

$IF <expr> 

and always ends with

$ENDIF 

The control statements

$ELSE 

and

$ELSEIF 

are optional and serve to build up multiple branching.

Notice

The condition in $IF-control-block is checked by verifying the mathematical expression for "true" or "not true" (TRUE and FALSE). To be able to use also decimal variables the jump condition is fulfilled (TRUE) if..
.. the absolute value of the mathematical expression is > or = 0.5.

Programming example

N10 ... 
N20 $IF P1 Only if |P1| is greater or equal to 0,5, the statements
N30 ... N30 to N50 will be executed.
N40
N50
N60 $ENDIF

But the following is also possible:

N10 ... 
N20 $IF P1 >= 0.5 Only if P1 is greater or equal to 0.5 , the statements
N30 to N50 will be executed.
N30 ...
N40
N50
N60 $ENDIF

or

N10 ... 
N20 $IF P1 > P2 Only if P1 is greater than P2, the statements N30 to N50
will be executed, otherwise the statements N70 to N90
N30 ...
N40 ...
N50 ...
N60 $ELSE
N70 ...
N80 ...
N90 ...
N100 $ENDIF

These use of ELSEIF permits:

N10 ... 
N20 $IF P1 == 0 Only if P1 is equal to 0, the statements N30 to N50
will be executed, otherwise the $ELSEIF-condition will
be checked, whether P2 >= 0.5 and accordingly N70 to
N90 or N110 to N130 will be executed.
N30 ...
N40
N50
N60 $ELSEIF P2>=0.5 The $ELSEIF-condition serves for building up
branching nesting into one another.
N70 ...
N80
N90
N100 $ELSE
N110 ...
N120
N130
N140 $ENDIF

Notice

According to the programming language C, there exists difference in the syntax between
A ssignment : P5 = 3 and
Comparison: $IF P5 == 3
For the version 2.3 and earlier ones : because in mathematical expressions always the sequence
Operator -> Term -> Operator -> Term -> etc
expected, for comparison operations, those expressions with a minus sign must be bracketed ("-" is interpreted as operator).

Programming example

$IF P1 >= -5 wrong, because term->operator->operator->term 
$IF P1 >= [-5] right, because term->operator->term->operator->term