Branching After Evaluation [ Command Interpreter Access and Variables Programmer's Guide ] MPE/iX 5.0 Documentation
Command Interpreter Access and Variables Programmer's Guide
Branching After Evaluation
Sequence within a command file or UDC can be controlled with the IF,
ELSEIF, ELSE, and ENDIF statements. When the conditions specified in the
IF statement are met, the actions following this statement are performed.
When the conditions are not met, an optional ELSEIF or ELSE statement
provides an alternative. Each IF construct must be ended with its
associated ENDIF statement.
IF statements can be nested, providing subsequent levels of conditions.
When nested, however, each IF statement must be ended by a matching ENDIF
statement. The following example is from the MENU command file shown in
the previous example. In this segment, the user's response to the input
prompt is evaluated to run the appropriate database processing program.
IF CHOICE = "1" THEN
DBREVIEW
ELSE
IF CHOICE = "2" THEN
DBUPDATE
ENDIF
ENDIF
The ELSEIF statement provides a combination of the ELSE and IF statements
and simplifies a nested IF construction. The MENU command file could
have been written using the ELSEIF construction. The following example
demonstrates how the ELSEIF statement simplifies the branching construct
in the MENU command file.
IF CHOICE = "1" THEN
DBREVIEW
ELSEIF CHOICE = "2" THEN
DBUPDATE
ENDIF
MPE/iX 5.0 Documentation