IF |
"if" is used to perform an action when a condition is realised.
Ifexpr1 [ Then ] [ instructions ]
{ Elsifexprn [ Then
] [ instructions ] } *
[ Else [ instructions ] ]
Endif
|
Element |
Description |
Restrictions |
|
expr1 |
expression_logique. |
None. |
|
exprn |
expression_logique. |
None. |
# Various tests
If I = 1
Infbox "I is
1"
Elsif I > 1 Then Print "I is
greater than 1"
Elsif I = 0 : Print
"I is null"
Elsif I > 0
Infbox "I is
between 0 and 1"
Else
Infbox "I is
negative"
Endif
# If sans Else
If I = 1 : Infbox
"I = 1" : Endif
# If with only one Else
If I = 1 : Infbox
"I = 1" : Else Infbox "I is different from 1" : Endif
If is used to provide alternatives within a programme. Else, Elsif are not mandatory, but an Endif is required to complete the alternative. There may be several Elseif for one If, but there may not be several Else.
In order to provide an alternative for one variable using constant values, Case may be used.
|
Error |
Description |
|
ERMODE (10) |
expr1 or exprm are not numerical types. |
|
|