up previous next
conditional statement
If B Then C EndIf
If B_1 Then C_1 Else C_2 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 C_r EndIf
D If B
where the B's are boolean expressions, the C's are command
sequences, and D is a single command.
|
If
B_n is the first in the sequence of
B_i's to evaluate to True,
then
C_n is executed. If none of the
B_i's evaluates to True, nothing
is done. The construct,
Elif B Then C can be repeated any number
of times. Note:
Elsif is no longer allowed.
In the last form, the single command D is performed if B evaluates to
True. NOTE: the use of this form is discouraged. It will probably
disappear from future versions of CoCoA.
For a conditional
expression, assignable to a variable, see
Cond
.
Define Sign(A)
If A > 0 Then Return 1;
Elif A = 0 Then Return 0;
Else Return -1;
EndIf;
EndDefine;
Sign(3);
1
-------------------------------
|