MENU

The MENU statement creates and displays a ring menu. With the keyboard or mouse, the user can choose menu options that execute blocks of statements.

4GLREF00000167.gif

title a quoted string that specifies a display label for the ring menu.

This statement specifies and displays a ring menu that occupies two lines in the current 4GL window.

The MENU statement can do the following:

Create and display a screen menu, including a title of the menu.

Define and display a list of menu options that the user can select.

Specify a single-line description to display for each menu option.

Designate Help message numbers for each menu option.

Specify a block of 4GL statements to execute for each menu option.

When it encounters a MENU statement, 4GL performs these actions:

  1. Displays in the current 4GL window the title and the options of the menu.

  2. Moves the menu cursor to the first option, and displays its description. (The order of options is determined by their order in the control blocks. The menu cursor marks the current menu option with a double border.)

  3. Waits for the user to press the activation key for a MENU control block, or to terminate the MENU statement by pressing the Quit or Interrupt key.

  4. If the user presses an activation key, 4GL executes the statements in the corresponding control block, until it encounters one of these statements:

EXIT MENU statement. 4GL then exits from the menu.

CONTINUE MENU statement. 4GL skips any remaining statements in the MENU control block, and re displays the menu.

Last statement in the MENU control block. 4GL re displays the menu so that the user can choose another option.

A menu can appear above or below a screen form, but not within a form. 4GL displays the menu title and the menu options on the Menu line. This reserved line is positioned by the most recent MENU LINE specification in the OPTIONS or OPEN WINDOWS statement. The default position is to the first line of the current 4GL window.

Unless the title and at least one option can fit on the screen or in the current 4GL window, a run-time error occurs.

The title of a menu is just a display label; you cannot reference a menu by name. To repeat the same menu and all its behavior in different parts of a program, you can include the MENU statement in a FUNCTION definition, so that you can invoke the function when you want the menu to appear.

The MENU Control Blocks

Each control block includes a statement block of at least one statement, and an activation clause that specifies when to execute the statement block. Any of three types of activation clauses can appear within MENU control blocks:

BEFORE MENU clause (to execute the block before the menu is displayed)

COMMAND option clause (to specify the name and description of an option, an optional activation key(s) to choose the option, and an optional Help message code; execute the block when the user chooses the option)

Hidden option clause (a COMMAND clause that only specifies activation key(s) to execute a statement block if the key is pressed; no option name, option description, nor Help message number is specified).

The statement block can specify SQL or other 4GL statements to execute when a user presses a key sequence, as well as special MENU instructions:

The next menu option to highlight with the menu cursor.

Whether to suppress or restore the display of one or more menu options.

Whether to exit from the MENU statement.

The activation clause and statement block correspond respectively to the left-hand and right-hand syntax elements in the diagram that follows:

4GLREF00000168.gif

key is a letter, a literal symbol in quotation marks, or a keyword. (Quotation marks are not required if key is a single letter of the alphabet.) This list of up to four (4) activation keys must be enclosed in parentheses.

number is an integer that identifies the Help message for this menu option. You must have used the OPTIONS statement previously to identify the Help file containing the message.

option description is a quoted string or the name of a CHAR or VARCHAR variable that contains an option description for the Menu help line.

option name is a quoted string or the name of a CHAR or VARCHAR variable that contains the name of the menu option. This cannot be longer than the width of the current 4GL window.

statement is an SQL statement or other 4GL statement.

The COMMAND Clause

The COMMAND clause can define a menu option that appear after the menu title in the Menu line, as well as its description that appear in the following line when the menu cursor is on the option. It has the following syntax:

4GLREF00000169.gif

Invisible Menu Options

You can add an invisible option (an option that is never displayed) to a menu by including a KEY clause in the COMMAND clause of the MENU control block, but not specifying an option name nor an option description.

4GLREF00000170.gif

The key cannot be the activation key of any other COMMAND clause. If you specify a letter here as the activation key, this must be different from the first character of any option of the same menu.

References

CONTINUE

DEFER

OPEN WINDOW

OPTIONS