Previous Topic: &DOWHILE

Next Topic: &ENCODE


&ELSE

&ELSE provides an alternative logic path after &IF where the preceding &IF condition is false.

&ELSE { command | statement }

The &IF statement specifies a course of action when the condition being tested is true. By coding an &ELSE statement with an &IF statement, an explicit course of action is specified whenever the &IF condition is false.

Where &ELSE is used to specify a false condition logic option, no &GOTO statement is required after a true condition.

&ELSE must be coded as a statement separate from the preceding &IF statement. If &ELSE is coded on an &IF statement, it causes a syntax error.

Operands:

command or statement

This specifies the command or statement which is to be executed when the &IF condition is false. The command or statement must be coded in the same statement as &ELSE.

Examples:

&IF &STATUS = ACTIVE &THEN +
 &DO
  -*
  -* True Logic
  -*
 &DOEND
&ELSE +
 &DO
  -*
  -* False Logic
  -*
 &DOEND
.CONT

In this example, true logic is executed if &STATUS = ACTIVE. On completing true logic, processing resumes at the label .CONT. If &STATUS is not equal to ACTIVE, the false logic after the &ELSE statement executes. When this completes, processing also resumes at the .CONT label.

Note: No &GOTO statement is required to direct the logic flow.

More information:

&DO

&IF