If-Then-Else Keyword
expression
Use
The IF-THEN-ELSE statement is an easy way to describe the progression from one
state to another in a state machine. The expression following the IF keyword
is evaluated, and if the result is true, the machine goes to the state
indicated by the state_exp following the THEN keyword. If the result of the expression
is false, the machine advances to the state indicated by the ELSE keyword.
Additional IF-THEN-ELSE statements can be chained to the ELSE clause of an
IF-THEN-ELSE statement. Any number of IF-THEN-ELSE statements can be chained, but
the final statement must end with a semicolon.
Example
[ ELSE state_exp ] ;
ELSE IF expression THEN state_expression
ELSE IF expression THEN state_expression
ELSE state_expression ;
Note: Equation blocks used within a conditional expression, such as If-Then-Else,
result in logic functions that are logically ANDed with the conditional
expression that is in effect.
CAUTION: If-Then-Else is only supported within a state_diagram description. Use When-Then-Else for equations.
if x-y then j else k; "if x-y is not 0 goto j, else goto k
if A then b*c; "if A is true (non-zero) goto state b*c
else
if b then 2
else
if c then 3
else 0 ;
See Also