The If statement is a compound statement that allows different blocks of code to run under a variety of conditions.
ifstmt ::= If condition Then stmtblock [[ elseifblock ]] [ elseblock ] EndIf ;
elseifblock ::= ElseIf condition Then stmtblock
elseblock ::= Else stmtblock
The condition is any expression that yields a Logical result.
The stmtblock is a standard list of statements with an optional OnError section.
The system will start by evaluating the first condition expression. If it yields a True result then the first statement block will be executed. If the condition yields False then any ElseIf conditions are evaluated in turn until one yields True, in which case the associated statement block is executed. If no conditions yield True the Else part, if one exists, will be executed. At most one statement block will be executed.
If x < 4 Then res := -1; ElseIf x > 4 Then res := 1; Else res := 0; EndIf;