VOC M-Type Records - Menu Definitions
A VOC menu record defines a menu of numbered options to be displayed to the user when the menu entry is executed. Because menu records may be very large, they are often stored in some other file with a VOC R-type record as a remote pointer to the actual menu definition.
A menu record has 11 fields:
The descriptions are normally displayed starting on the third line of the screen, left justified. If the menu has more items than will fit in a single column on the screen and the items are all sufficiently short, the menu will be displayed as two columns. Any menu items that will not fit on the screen are lost.
Menus may be constructed and maintained using the menu editor MED.
A summary of M-type VOC records may be displayed or printed using LISTM.
A menu may include run time selection of which options are to be offered to the user. This is managed by a user written access control subroutine named in field 8 of the menu definition. When the menu is displayed, this subroutine is called for all entries that have an access key defined in field 6 to determine whether the option is to be offered. The subroutine takes three arguments; the returned True/False accessibility flag, the menu name and the access key. Typically, the access key would be a name that refers to a group of users such as ADMIN or SALES. Access control subroutines may be used by multiple menus and, where necessary, can use the menu name in the decision process that controls display. The subroutine should return the first argument as True (or numeric value 1) if the menu item is to be allowed, False (or numeric value 0) if it is to be disabled.
Field 7 of the menu definition contains the "hide" flag which controls the action taken when a menu option is disabled for a user. Setting this to 0 or leaving it blank, displays the option with its option number enclosed in parentheses. Entry of this option number at the menu prompt will be ignored. Setting the hide flag to 1, completely hides the disabled option.
An example of a simple access control subroutine is shown below:
SUBROUTINE ACCESS(OK, MENU.NAME, KEY)
CASE KEY = 'ADMIN'
OK = (@LOGNAME = 'ADMINISTRATOR')
OK = @FALSE
OPEN 'USERS' TO USER.F THEN
READ USER.REC FROM USER.F, @LOGNAME THEN
OK = (USER.REC<U.DEPT> = KEY)
For an access key of ADMIN, this subroutine enables the menu option only if the user is logged in as an administrator. For all other access key values, it reads a user record and checks that the user is in the relevant department. The U.DEPT token used above would be defined in an include record.