Menu Generation Program |
When creating a new template using Template Designer Wizard or modifying an existing template using Template Maintenance, you can Define a Menu to add to a section of the template.
If you want to define a simple menu with static contents, you can enter the individual menu components in the Menu Contents grid (the Define Menus window in the Template Designer Wizard or the Menus tab in Template Maintenance). However, situations may arise where other factors need to be considered when creating the menu contents. For example, the data source for the menu changes periodically or security checking needs to be applied to the menu contents. To define a menu that will address these types of situations, you can create a PxPlus program to generate the menu contents and then enter that program name in the Menu Generation Program field in the Define Menus window in the Template Designer Wizard or the Menus tab in Template Maintenance. A Menu Generation program eliminates the need to define the menu contents manually. Once the name of a Menu Generation program is entered, you can then specify other menu settings such as layout, border, background color/image, text color, etc.
(The ability to specify a Menu Generation Program was added in PxPlus 2016.)
This page explains how you can create your Menu Generation program to generate menu contents.
To give you an example, the ide template was used to generate the interface below. You can select this template in Template Maintenance and look at the settings on the Sections tab. When Section 2 is selected, the Section Contents grid indicates that a menu with Menu Name=main has been defined with its positioning on the bottom of this section, horizontally centered. The Menus tab shows that the menu was generated by running the Menu Generation Program *ide/inomads/imp_ide.mnu. This section with its menu defined is highlighted below.
To guide you in creating your Menu Generation program, you may find it helpful to review the code in the *ide/inomads/imp_ide.mnu program using *IT - Integrated Toolkit, Ed+ or any other program editor.
When iNomads runs a template with custom menu settings defined, the menu data is read from the template's custom.ini file for processing. Each menu and sub-menu is assigned a menu number. If a Menu Generation program has been specified, the iNomads program creates a memory file and passes the file handle (menu_mem), along with the current menu number (menu_no), to the Menu Generation program. The Menu Generation program is responsible for populating the memory file, using a specific record format. If sub-menus are required, the value of menu_no may be incremented. When completed, the Menu Generation program will EXIT, allowing the iNomads program to merge the records from the memory file and continue processing.
To receive the menu_mem and menu_no values, every Menu Generation program must contain the following ENTER statement:
ENTER menu_mem,menu_no
The format for the write to the memory file is:
WRITE(menu_mem, KEY=key$)name$,text$,url$
Where:
key$ |
To conform to the formats of the menus defined in the custom.ini file, the key value must be in the following format: "[Menu"+STR(mnuNo:"00")+"_"+STR(mnuSeq:"00")+"]" Where: mnuNo is the menu number. Examples: [Menu01_03] indicates that this is the key for the third item on Menu One. | ||||||||||||||||
name$ |
Typically is the name of the task used to generate a new menu name for sub-menus. | ||||||||||||||||
text$ |
Text to display for the menu selection. See Menu Contents in Template Maintenance. | ||||||||||||||||
url$ |
URL value for the menu selection. Can contain a number of values. See Menu Contents in Template Maintenance. Examples:
|
When the Menu Generation program is completed, an EXIT statement is needed to return to the calling program.