Else

Command groupFlag affectedReversibleExecute on clientPlatform(s)
ConstructsNONOYESAll

Syntax

Else

Description

This command is used after an If command to mark the beginning of some commands that are carried out if the condition in the preceding If command is false.

Example

# In the example below, the value of lGender is tested against the condition

# specified in the If statement.  If the condition fails, control branches to the

# first Else If statement in the method. If the condition again fails, control

# branches to the Else command.

 
If
 
lGender
=
'M'

  
OK message
 
{
Record is MALE
}

Else If
 
lGender
=
'F'

  
OK message
 
{
Record is FEMALE
}

Else

  
OK message
 (
Sound bell
)
 {
GENDER Unknown for this record
}

End If
 
# The same result could also be obtained using a switch statement

Switch
 
lGender

  
Case
 
'M'

    
OK message
 
{
Record is MALE
}

  
Case
 
'F'

    
OK message
 
{
Record is FEMALE
}

  
Default
    
OK message
 (
Sound bell
)
 {
GENDER Unknown for this record
}

End Switch