Menu programs use two types of commands: organizational and control. The following sections describe these commands and their options.
Organizational commands establish the content and organization of the menus the user sees on the screen. Use these commands to determine what the menus look like.
Table 36 gives an overview of the organizational commands. Detailed information about each command follows the table.
Table 36. NMENU Organizational Commands
| Command | Explanation |
|---|---|
MENU |
Marks the beginning of a new menu or submenu screen in the text. |
ITEM |
Identifies an item to be listed on the menu. Specifies execution parameters. |
Indicates a new window definition within your menu file.
MENU menu_number,menu_name
Replace menu_number with the number you want to assign to this menu. Menus are called and displayed by their number.
A menu number can be any number from 1 through 255. Each menu within a source file must be assigned a unique number, but the number sequence doesn't matter.
Replace menu_name with the title you want to appear at the top of the menu. Menu names can be a maximum of 40 characters long.
The first menu defined in the source file is always the first menu displayed, no matter what number is assigned to it. Subsequent menus are referenced by their numbers, no matter what order they appear in the .SRC file.
For example, if you have defined three menus and assigned them numbers 1, 2, and 5, and menu 5 is the first menu in the source file, menu 5 is displayed first. Menus 1 and 2 are referenced in control commands and displayed depending upon user selection.
To define a main menu for a program to be used by accountants in your company, type a line similar to the following:
MENU 1,Accounting Main Menu
Since this is the first menu you want to appear, place it at the beginning of your menu program.
Indicates an option in the menu.
ITEM item_name {[option...]}
Replace item_name with the list item you want to appear in the menu. The maximum length for an item is 40 characters.
Replace option with one or more of the options shown in the following table. Separate multiple options with a space. Enclose all options for a single ITEM in a single set of braces.
These options provide you with better control of menu execution. You determine how memory is used, which directory the user remains in, and what information is presented to those users.
Table 37. ITEM Command Options
| ITEM Option | Explanation |
|---|---|
BATCH |
Removes the menu program from memory before executing the item. Without this option, a portion of the memory stays resident, requiring approximately 32 KB of available memory, even though an application may be running. For example, if you enter ITEM Word 5.0 {BATCH} the menu program is removed from memory when Word 5.0 is executed. Setting this option automatically sets the CHDIR option. Don't use this command with the EXEC DOS command; use EXEC CALL. For more information, see EXEC. |
CHDIR |
Changes back to the drive and directory that were in effect before an ITEM was executed. For example, to change back to the drive and directory the user was in before executing a word processing application in another directory, type] ITEM WordPerfect 5.0 {CHDIR}. When the word processing application is closed, the directory is changed to the original directory for the menu. |
PAUSE |
Allows users to read messages associated with a command being executed from the menu, by pausing the screen display. The message Press any key to continue is also displayed, and the screen does not change until a user presses a key. For example, to display a message when a user selects the item DOS Copy from the menu, include the line: ITEM DOS Copy {PAUSE} When the copy function is complete, the display waits at the Press any key... prompt for a key to be pressed before returning to the menu. |
SHOW |
Displays the command name, such as COPY or DIR, in the upper left corner of the screen. For example, if you enter ITEM Copy Files {SHOW} the DOS command COPY is displayed when the item is executed. |
List items appear on the menu in the order in which they appear in the source file. They are not displayed in alphabetical order.
Each item is automatically assigned an alphabetic selection character.
If you want to assign a different character, place a carat (^) and the character you want in front of the item name (no spaces).
NOTE: Forcing the selection character shortens the maximum line length to 38 characters.
If you assign selection letters, you should assign them to all menu list items. Otherwise another item may be automatically assigned a character you have previously assigned.
For example, if the first menu item is Word Processing and you want to assign it the letter W instead of the automatic letter designation of A, type
ITEM ^WWord Processing
Control commands tell NMENU how to perform an action, such as displaying a submenu or user prompt, performing a DOS function, or starting an application. You also use these commands to tell the menu program how to process information and execute commands.
Table 38 gives an overview of the control commands. Detailed information about each command follows the table.
Table 38. NMENU Control Commands
| Command | Explanation |
|---|---|
EXEC |
Executes a DOS or NetWare command following an ITEM statement. |
SHOW |
Displays a submenu from the same .DAT file. |
LOAD |
Calls and displays a menu as a submenu from a different .DAT file than the one you are running. |
GETO |
Requests information from the user before a menu item is executed. User input is optional. (See GETx (GETO, GETP, GETR).) |
GETP |
Requests information from the user before a menu item is executed. User input is required for the program to proceed. Assigns a variable (%n) to the information so it can be used again. (See GETx (GETO, GETP, GETR).) |
GETR |
Requests information from the user before a menu item is executed. User input is required for the program to proceed. (See GETx (GETO, GETP, GETR).) |
Instructs NMENU to perform the command that follows EXEC.
EXEC command
Replace command with the command required to execute the ITEM. This could be the name of an executable file, a DOS or NetWare command, or one of the options associated with EXEC. The EXEC options are described in Table 39.
Table 39. EXEC Command Options
| EXEC Option | Explanation |
|---|---|
EXEC CALL |
Runs a batch file, and returns to NMENU. If you want to return to NMENU after a batch file executes, use this command to call batch files. |
EXEC DOS |
Runs the DOS command processor. If this command is used, the menu user must type EXIT when DOS processing is completed in order to return to NMENU. |
EXEC EXIT |
Exits the user from NMENU, but leaves the user logged in to NetWare. For security reasons, users cannot access the NetWare prompt unless this command is included in the menu. |
EXEC LOGOUT |
Exits the user from NMENU and logs the user out of the network, leaving the user at the DOS prompt. (See Setting Up the User Environment.) |
EXEC must follow the ITEM it applies to. It must also follow other control commands needed by ITEM.
To load Word 5.0 from a menu, include the two following lines in the menu file:
ITEM Word 5.0
EXEC word5
Instructs NMENU to execute a separate menu file.
LOAD filename
Replace filename with the name of another NMENU program.
If you have several menu programs created with the .DAT extension, use this command to call another menu program from the active menu program. LOAD always calls menus by their filename, not number.
Use this command when you have multiple menu programs defined. Although you can define up to 255 menus per source file, smaller, separate files are easier to manage and update.
The NMENU file being loaded must be in the current directory, or you must have a search path to the file defined.
If you are writing a menu program for Sales and you want to call up the Accounting menu program, type
MENU 1,Sales Main Menu
ITEM Accounting Menu
LOAD ACCOUNT
Instructs NMENU to execute a submenu defined within the same file.
SHOW menu_number
Replace menu_number with the number of the submenu to be displayed.
Include SHOW commands to identify the submenu to be displayed when an item is selected from a menu.
SHOW commands always use menu numbers, not titles.
If you have a menu with items listing categories of applications such as Word Processing and Spreadsheets, each ITEM has the following SHOW commands to call up the appropriate submenus for those categories:
ITEM Word Processing
SHOW 3
ITEM Spreadsheets
SHOW 5
To continue this example, if menu 3,Word Processing is a list of available word processing programs needed by both Sales and Accounting, and each group has its own menus defined, the programs can share that screen and the screen's calls to execute the applications.
The GETx commands provide access to user input. You can request or require user input. You can even store user input for future use. Each variation of the GETx command uses the same parameters to control what the users sees and does. Pay close attention to the use of spaces, commas, and braces { }.
GETx prompt {prepend} length,[prefill ], {append}
Replace x with the letter O, R, or P.
Replace prompt with the text (instructions) to be displayed to the user (40 characters maximum). For example: Enter your Password.
Prepend is a value added to the beginning of the user response. A space is usually required in the first GETx command, to separate it from the command issued in its associated EXEC command.
Replace length with the maximum number of characters the user can enter. This parameter is required. For example, if you use GETR for a phone number, limit the length to 11 characters to match the field length for the phone number. Or, if you want a state or country abbreviation entered, limit the length to two characters.
Replace prefill with a default response displayed with the prompt. The user can accept the default, change the response by typing over the default, or cancel selection of the item. Prefill cannot be longer than the specified length.
The prefill parameter is optional. If you do not want to include a default response, enter the two commas together. (See the GETx examples on the following page.)
Append is the value added to the end of the user response. If no value is needed, enter braces with a blank space between them.
NOTE: Append doesn't work with GETP.
Following are some general guidelines on the use of the GETx commands.
GETR Please enter the project code: { } 08,, { }
GETR Please enter your password: {} 08,, {}
GETO Load default macros? { } 01,, { }
GETR Enter the loan amount: { } 7,,{ } GETR Enter the interest rate: { } 5,8.5, { } GETO Enter the period (/m=months or /y=years):+ { } 7,/y=30, { } EXEC mortgage
The iFnput values will be appended to the EXEC mortgage command before it is executed.
GETP Enter the loan amount: { } 7,,{ } GETP Enter the interest rate: { } 5,8.5, { } GETP Optional-Enter the period (/m=months or+ /y=years): { } 7,/y=30, { } EXEC echo %1 EXEC echo %2 EXEC echo %3 EXEC mortgage %1 %2 %3 EXEC pause