Main page Reference Manual

Extending x-4gl

Menu functions

Functions to produce vertical menus are contained in the menu.4gl module. The following example shows a typical program stub to produce a menu:

The menu object is initialized with 'menuopen' which supplies the menu title. Menu items are then set up with 'menuline' which supply the label text. The menu is then generated and displayed on the screen with 'menusetup'.

User responses are handled by 'menuman'. The only user responses that are handled by the calling program are exit requests and legal menu item numbers. The calling program can act on these responses by testing the return value from 'menuman'. Other user responses, such as requests for help, print-screen, operating system commands, cursor movement and illegal menu item numbers are handled automatically within 'menuman'.

Finally, the menu object is removed with 'menuclose'.

Following are more detailed descriptions of the functions in the menu system:

Menuopen

Initializes a menu object with a title and screen position.

2 parameters:
Title: A title string or a key into the title text file. More than one title line can be defined in the title text file.
Row: Optional row position of the menu window.
Column: Optional column position of the menu window.

If the row and column parameters are not specified, then the menu will be positioned two rows down and one column farther right than the previous menu, producing a cascading effect. If no previous menus are active, the menu will be positioned in the top left corner of the screen.

Menuline

Sets up one simple menu item.

2 parameters:
Label: A label string or a key into the label text file.
Type: Character value used as part of the key into the label text file. 'm' indicates a sub-menu and the label is followed by '...'.

Menufline

Sets up one menu item with options.

3 parameters:
Label: A label string or a key into the label text file.
Type: Character value used as part of the key into the label text file. 'm' indicates a sub-menu and the label is followed by '...'.
Active flag: Logical value indicating whether the menu item should be active (true) or inactive. Inactive menu items appear in a different shade and are not accessible by the user.

Menusetup

Displays the menu object, which has been defined with 'menuopen' and 'menuline/menufline', in a bordered window. The size of the menu is automatically determined from the size of the titles and labels, and the number of menu items.

Menuman

Handles user responses to a menu object, returning either a selected legal menu item number or an exit request.

1 return value:
Item: An item number or the number zero, which indicates a request to exit the menu.

Menuclose

Closes the menu object, removing it from the screen.


Power-4gl manual main page