LEVEL [ HP Transact Reference Manual ] MPE/iX 5.0 Documentation
HP Transact Reference Manual
LEVEL
Defines processing levels within a program.
Syntax
LEVEL[(label([item-name]))];
LEVEL specifies a new processing level. LEVEL allows repeated entries
and retention of information during data entry and eliminates redundant
data entry operations. The data register, key register, match register,
list register, update register, SET(DELIMITER) and SET(OPTION) are unique
to that level. When an end of level occurs, these registers and settings
are reset to the condition they were in on entering the level.
Statement Parts
label The statement to which the program should branch at the end
of the level sequence if the user enters "]" in reply to a
program prompt.
item-name The location in the list register where the pointer is to
be set.
If you do not specify item-name, for example,
LEVEL(label());, the list register is reset to empty.
If you use an "*" instead of item-name, as in
LEVEL(label(*));, the list register is reset to the
condition it was in on entering the level.
Exits From LEVEL Sequences
If no label is specified, four types of exits from LEVEL sequences are
possible;. two of which the user controls and two of which the
programmer controls. They are described below.
] When the user enters "]" in response to any prompt in a
level sequence, control passes to the previous processing
level, which may be the command level or to the label
specified in LEVEL(label). Any changes made to the match,
list, or update registers within the level are reset to
their original state.
]] When the user enters "]]" in response to any prompt in a
level sequence, control passes to the Transact command
level, or if not in a command sequence, Transact issues the
EXIT or RESTART(E/R)> prompt.
END(LEVEL) The end of the current level. This causes control to fall
through to the statement following the END(LEVEL) statement
and resets the match, list, or update registers to whatever
their conditions were immediately before the last level
sequence began.
END If you use END without (LEVEL) to terminate a level,
Transact generates a loop after the first execution of the
level. The loop begins at the top of the level. The
match, list, or update registers are reset to whatever
their values were at the beginning of the level.
Examples
Nested level sequences are possible, as this example shows. The
following statements minimize the data entry required for a sequence of
entries for a time card. It requires values for year and month, then
multiple entries for employee. Each level change provides the
opportunity for the user to enter data.
PROMPT YEAR:
MONTH;
LEVEL;
PROMPT EMPLOYEE;
LEVEL;
PROMPT DAY;
LEVEL;
PROMPT ACTIVITY: <<A loop through this level resets >>
HOURS; <<list REGISTER and data register for >>
PUT TIME-RECORD; <<these data items (activity, hours). >>
END;
END;
END;
Execution of these statements causes a prompt for each data item value
and then a loop at the lowest level. When the user has entered all
activity items for a specific day, he or she should enter a "]" in
response to "ACTIVITY". Control passes to the next higher level and user
is prompted with "DAY". When all days have been entered for one
employee, the user should enter "]" in response to "DAY". Control passes
to the next higher level and the user is then prompted for the next
employee.
MPE/iX 5.0 Documentation