Conditional rules
In this section we give the rules for setting up conditional statements (if/then rules)
Conditional Statements (Rules)
The conditional statement has the following general form:
if <boolean expression 1> then
statement
statement
:
[elseif <boolean expression 2> then
statement
statement
: ]
[elseif <boolean expression N> then
statement
statement
: ]
:
[else
statement
statement
: ]
endif
-
The conditional statement can have any number (0 or more) of 'elseif' clauses.
-
The 'else' clause is optional.
-
The conditional statement evaluates boolean expression 1. If the expression is true, the statements after the first 'then' are executed and control passes to the statement following the 'endif'. If the expression is false the boolean expression in the next 'elseif' clause is evaluated. If that is true the statements in that clause are executed and control pass to the statement following the 'endif', otherwise the next 'elseif' is evaluated.
-
This continues until there are no more 'elseif' clauses.
-
If none of the statement blocks execute, the statements in the 'else' clause, if present, are executed.
Example
if input1 > 5 then
output1 := 1
endif
if input2 <= 10 then
output1 := 1
elseif input2 <= 21 then
output1 := 2
elseif input3 > -5 then
output1 := 3
output2 := 1
else
output1 := 0
output2 := 0
endif
Related topics: