Defining menus

A menu, also called a selection panel (Figure 1), is a special type of panel.

The sections that can be used in a menu definition are the same as those that can be used in other panel definitions. However, a menu requires a processing section in addition to the body section. The processing section must be in a special format.

Menu definitions are processed by the SELECT service. A menu must have an input field to allow users to enter selection options. Generally, this is the command field, and is the first input field on the panel. This field should be named ZCMD to be consistent with the field name used in this guide.

Besides ZCMD, a menu can have input fields to set up dialog variables needed by that application. Any variables other than ZCMD and ZSEL (or OPT and SEL) that are set from a menu are automatically stored in the shared variable pool.

Variables from the shared pool, including system variables, can also be displayed on a menu to provide information to users.

The required processing section must provide for the variable ZCMD to be truncated at the first period and then translated to a character string. The results must be stored in a variable named ZSEL.

The processing section of a menu is in this general format:

)PROC
  &ZSEL = TRANS( TRUNC(&ZCMD,‘.’)
           value, ‘string’
           value, ‘string’
                    ⋮
           value, ‘string’
                  ‘ ’, ‘ ’
                    *, ‘?’      )

The maximum length for ZSEL is 80 characters. If ZSEL is assigned a string longer than 80 characters, the string is truncated.

The ZCMD variable is truncated before translation to allow users to bypass one or more intermediate menus. For example, 1.2 means primary option 1, suboption 2. This is generally called a nested option. ZCMD is automatically stored, untranslated, as entered. When the SELECT service discovers that variable ZCMD contains a period, it causes the next lower-level menu to be selected with an initial option of everything following the first period. As long as the initial option is nonblank, the lower-level menu is processed in the normal fashion but is not displayed to the user.

Each value is one of the options that can be entered on the menu. Each string contains selection keywords indicating the action to occur. The selection keywords are:

Except for EXIT, each string of keywords must be enclosed in single quotes because it contains parentheses, and sometimes blanks.

These selection keywords are the same as those that can be specified for the SELECT service:

The PANEL keyword, for example, is used to specify the name of a lower-level menu to be displayed. The CMD and PGM keywords are used to invoke a dialog function coded in a command procedure or programming language, respectively. NOCHECK, MODE, and EXIT are described in the following topics.