Computers: Universe: Menus of Commands

You can build menus for your applications without coding by using UniVerse's own 'menu procressor'. Just define your menu as a record in a menu definition file, entering lists of option names and associated commands. UniVerse then uses this information to display your menu, process the replies, and execute the commands.

First create a file to store your menus:

>CREATE.FILE MY.MENUS DYNAMIC
Creating file "MY.MENUS" as Type 30.
>

The UniVerse menu editor itself begins with a UniVerse menu. To bring it up onto your screen, enter the command:

>MENUS

UniVerse Menu Maintenance

 1. Enter/Modify       a menu
 2. Enter/Modify       a formatted menu
 3. Display            a summary of all menus on a menu file
 4. Display            the contents of a menu
 5. Enter/Modify       a VOC menu selector item
 6. Enter/Modify       a VOC stored sentence item
 7. Display            all menu selector items on the VOC file
 8. Display            all stored sentence items on the VOC file
 9. Display            the dictionary of a file
10. Print              a summary of all menus on a menu file
11. Print              the contents of a menu
12. Print              a virtual image of a menu on the printer
13. Print              the contents of a formatted menu
14. Print              the dictionary of a file
15. Print              detail of a menu, including VOC records referenced

Which would you like? ( 1 - 15 )  ?

Select option 1 to enter your new menu:

Which would you like? ( 1 - 15 ) ?1
Name of MENU file=

Your menu file is called MY.MENUS, so:

Name of MENU file=MY.MENUS

 MENU PROCESS DEFINITIONS  REVISE.1  Fri Aug 20 14:43:39 1999


MENU.NAME= 

You may find this sparse screen layout familiar. In fact, you've seen something like it before, because UniVerse uses REVISE to provide a menu maintenance screen (see The REVISE Command). For this example, we'll call your menu EXAMPLE.MENU:

MENU.NAME= EXAMPLE.MENU
New record.
TITLE= My example menu

MENU PROCESS DEFINITIONS -Screen 2-MENU SELECTION ITEMS Fri Aug 20 14:48:41 1999 MENU.NAME==> EXAMPLE.MENU No. DESC............................... ACTION......... EXP................. 1 DESCRIPTION=

Having entered a key for your menu record, and a title to display at the top of the menu, you are now prompted for the description of your first menu option. In fact, for each menu item you wish to create, you will be prompted for three pieces of information: a description (to display on the screen), an command to display on the screen if the menu option is selected by the user, and an optional 'explanation' to display if the user asks for help concerning the option.

The first command will display a simple VOC listing, so try the following values:

DESCRIPTION= List the VOC
ACTION= LIST VOC BY @ID
EXPLANATION= Display a sorted list of all the records in the VOC file

As soon as you have pressed return at the end of this explanation, you will be prompted for another menu item. Try this one:

DESCRIPTION= Say hello
ACTION= BLOCK.TERM HELLO
EXPLANATION= A warm greeting

Once you have finished entering options, simply press ENTER at the DESCRIPTION= prompt:

DESCRIPTION= (Press ENTER)

As usual, REVISE will redisplay the list of multivalues to allow you to change them. Press ENTER again:

MENU PROCESS DEFINITIONS -Screen 2-MENU SELECTION ITEMS Fri Aug 20 15:01:38 1999

MENU.NAME==> EXAMPLE.MENU
No. DESC............................... ACTION......... EXP.................
1 List the VOC LIST VOC BY @ID Display a sorted lis
2 Say hello BLOCK.TERM HELL A warm greeting
3

Change which line item= (Press ENTER)

Then press ENTER again to file the menu record:

MENU PROCESS DEFINITIONS -Screen 1-MENU NAME AND TITLE Fri Aug 20 15:03:21 1999

1 MENU.NAME EXAMPLE.MENU
2 TITLE My example menu

S1 == MENU NAME AND TITLE
S2 == MENU SELECTION ITEMS

CHANGE= (Press ENTER)

And (unusually for REVISE) enter QUIT when asked if you'd like to edit another menu record:

MENU PROCESS DEFINITIONS REVISE.1 Fri Aug 20 15:04:37 1999


MENU.NAME= QUIT

All of which will bring you back to the original menu:

UniVerse Menu Maintenance

 1. Enter/Modify       a menu
 2. Enter/Modify       a formatted menu
 3. Display            a summary of all menus on a menu file
 4. Display            the contents of a menu
 5. Enter/Modify       a VOC menu selector item
 6. Enter/Modify       a VOC stored sentence item
 7. Display            all menu selector items on the VOC file
 8. Display            all stored sentence items on the VOC file
 9. Display            the dictionary of a file
10. Print              a summary of all menus on a menu file
11. Print              the contents of a menu
12. Print              a virtual image of a menu on the printer
13. Print              the contents of a formatted menu
14. Print              the dictionary of a file
15. Print              detail of a menu, including VOC records referenced

Which would you like? ( 1 - 15 )  ?

Where you can finally press ENTER to return to the UniVerse prompt.

You need now to create a menu pointer in your VOC file before you can invoke your menu. The first line (like all VOC records) carries the type of the record, an M, followed by an optional description. The second line contains the name of the menu file, and the third the key to the menu record. Create one like this:

>ED VOC EXAMPLE.MENU
New record.

----: I
0001= M Example menu created during training
0002= MY.MENUS
0003= EXAMPLE.MENU
0004= (Press ENTER)
Bottom at line 3.
----: FI
"EXAMPLE.MENU" filed in file "MY.MENUS".
>

Finally invoke your menu via this menu pointer by typing:

>EXAMPLE.MENU

My example menu

 1. List the VOC
 2. Say hello

Which would you like? ( 1 - 2 )  ?

Trying option 1 displays:

LIST VOC BY @ID 15:16:11  20-08-99  PAGE 1
NAME..........    TYPE    DESC..........................

#                 K       Keyword - "Not Equal"
%                 K       Keyword - Calculate
                          percentages
&                 K       Keyword - The Boolean
                          conjunction "AND"
&COMO&            F       F 1,1 used for COMO listings
&DEVICE&          F       File - Contains all logical
                          device names
&ED&              F       F 0 0
&HOLD&            F       F
&MAP&             F       File - Used by MAKE.MAP.FILE
&PARTFILES&       F       File - Contains all parts of
                          Distributed Files
&PH&              F       F
&SAVEDLISTS&      F       F
&UFD&             F       File - Used by uniVerse to
                          access the current directory.
(                 K       Keyword - "Open Parenthesis"
)                 K       Keyword - "Close Parenthesis"
*                 K       Keyword - SQL multiplication
Press any key to continue...

Press Q to escape the listing and then press ENTER to return to the menu. Option 2 displays:


    HHHH    HHHH   EEEEEEEEEEEE   LLLL           LLLL            OOOOOOOOOO
    HHHH    HHHH   EEEEEEEEEEEE   LLLL           LLLL           OOOOOOOOOOOO
    HHHH    HHHH   EEEE           LLLL           LLLL           OOOO    OOOO
    HHHHHHHHHHHH   EEEEEEEEEE     LLLL           LLLL           OOOO    OOOO
    HHHHHHHHHHHH   EEEEEEEEEE     LLLL           LLLL           OOOO    OOOO
    HHHH    HHHH   EEEE           LLLL           LLLL           OOOO    OOOO
    HHHH    HHHH   EEEE           LLLL           LLLL           OOOO    OOOO
    HHHH    HHHH   EEEEEEEEEEEE   LLLLLLLLLLLL   LLLLLLLLLLLL   OOOOOOOOOOOO
    HHHH    HHHH   EEEEEEEEEEEE   LLLLLLLLLLLL   LLLLLLLLLLLL    OOOOOOOOOO













Press any key to return to the menu... 

Again, pressing ENTER will return you to the menu.

To display the help you entered for the options, enter an option number followed by a question mark:

Which would you like? ( 1 - 2 ) ?2?
A warm greeting

To access the general help on menus, which explains all this, simply enter a question mark:

Which would you like? ( 1 - 2 ) ??

                                   MENU
                                   ----





       Typing in the number preceding the description of the selection
             that you wish to run will start the desired process.


                 To exit from this menu, just type .


        If you wish further information about any selection, just type
          in the selection number followed by a question mark ("?").

   For example:
          "1?" will give further information on selection number one.




Press any key to return to the menu... 

Don't forget that each menu pointer in the VOC file is itself a valid command, and so can be invoked as the action of an option on another menu. Using this technique, you can develop nested menu structures.

The menu processor also allows you to create menus in which the exact coordinates at which option is displayed can be defined, as can the string the user must type in to escape the menu: but the principle behind them and the creation is much the same: as usual, refer to UniVerse documentation for the tricksy stuff.