up previous next
if

conditional statement

Syntax
If B_1 Then C_1 EndIf
If B_1 Then C_1 Else D EndIf
If B_1 Then C_1 Elif B_2 Then C_2 Elif ... EndIf
If B_1 Then C_1 Elif B_2 Then C_2 Elif ... Else D EndIf

where the B_j are boolean expressions,
and the C_j and D are command sequences.

Description
If B_n is the first in the sequence of the B_j to evaluate to True, then C_n is executed. If none of the B_j evaluates to True, then D is executed if present otherwise nothing is done. The construct, Elif B_j Then C_j can be repeated any number of times.

NB: Elsif is no longer allowed.

Example
  Define Sign(A)
    If A > 0 Then Return 1;
    Elif A = 0 Then Return 0;
    Else Return -1;
    EndIf;
  EndDefine;
/**/  Sign(3);
1

See Also