Syntax
ELSE
Description
The Else logic command introduces a sequence of logic statements to execute if the specified conditional expression of its associated DoWhen logic statement evaluates as false. It is preceded by a DoWhen logic statement, and followed by a sequence of logic statements, and then by an End, EndExit, or EndNoPrint logic statement.
The Else logic command is valid with nested DoWhen logic statements. Each Else logic statement introduces a sequence of logic statements to be executed if the specified conditional expression of the current DoWhen logic statement evaluates as false. Only one Else logic statement can be associated with each DoWhen logic statement.
Note: An EndExit logic statement following an Else logic statement applies only to the Else logic statement, rather than the associated DoWhen logic statement. Refer to dowhen, Else for more information.
Examples
Example 1
This example adds increments to the Total variable if A equals B, but decrements Total if A is not equal to B.
If A = B Total := Total + 1 Else Total := Total - 1 End
Example 2
This example uses the second Else logic statement to display a message if the specified conditional expression of the first DoWhen statement is not true, that is, when A is not equal to B. In this case, the nested DoWhen logic statement and its associated Else logic statement are not executed.
If A = B If C = D Message Attention "A = B and C = D" Else Message Attention "A = B and C <> D" End Else Message Attention "A <> B" End