CHAPTER 1 MENU SYSTEM MENU SYSTEM GENERAL INFORMATION 1.1 GENERAL INFORMATION The menu system is a software program that allows a software system (group of related programs) to interact with a person. The menu system displays menus with up to 9 selections for the person to choose from by entering a number. They can display another menu at a lower level or depress the 0 key and return to a higher level. Further, they can run a program at their terminal or start a job that will run separately, called a batch job. The command format is : $ MENU [] The form-library-name is the name of a form library which contains a group of menus. The menu system can only use one form library per execution. The menu system displays the form 'MAINMU' as the main menu of the group. It is necessary to become familiar with the VAX/FMS form editor. The menu system gets all of the control information from menu forms in the specified form library. The control information is stored in the named data section of the form using the VAX/FMS form editor or form language. The subprocess-name is the name given to the process that executes all of the images or command procedures that are selected on the menu. A subprocess does the work, since the menu system image is executing in the current process. A menu is a VAX/FMS form with the following elements, a title, a menu id, a maximum of 9 choices, a selection prompt, and a selection field. 1.1.1 A Title The title is centered on line one. It is concise and MENU SYSTEM MENU SYSTEM Page 1-2 consists of all capital letters. 1.1.2 A Menu Id The menu id is the VAX/FMS form name. Using the menu id, a programmer will know the form name to make any changes. The menu id is placed on line two and right justified. 1.1.3 A Maximum Of Nine Choices A maximum of nine choices are allowed. They are numbered from one to nine. Zero is reserved for exiting the current menu to the previous menu if there is one. Each choice has the selection number in column 20, a period in 21, and the selection description starting in column 25. The description (in upper and lower case ) will be clear and concise with no abbreviations. The selections should be arranged in groups of three for easier recall. 1.1.4 A Selection Prompt The selection prompt, 'Selection:' for example, is placed on line 19 a few spaces before the selection field. 1.1.5 A Selection Field The selection field, which must be called 'SELECT', is a one character field on line 19 and col 20. The field should be autotab to allow single keystroke selections, but this is not necessary. MENU SYSTEM MENU SYSTEM Page 1-3 The following is an example menu form: +---------------------------------------------------------------+ | A TITLE CENTERED | | MENUID| | | | | | | | | | | | 1. First | | 2. Second | | 3. Third | | | | 4. Fourth | | | | | | | | | | | | | | Selection: _ | | ^ | | | | | +---------- SELECT field | +---------------------------------------------------------------+ SETTING IT UP 1.2 SETTING IT UP The only connection between the selection number and the description is their proximity to each other in the form layout. The selection description describes what can be done and the number they select is used as the name key into the named data section of the form. For each form there are a number of named data items that are required to tell the menu system what to do when a selection is chosen. A selection has one named data item, whose name is the selected number, which describes that selection for the menu system. The following describes these named data items required for the menu system. 1.2.1 Specifying The Range Of Selections The named data item named 'RANGE' is message printed on the last line of the menu to tell the user what to select. For our previous example the 'RANGE' named data item could have been: Depress 1,2,3 or 4, to exit depress the 0 key. MENU SYSTEM MENU SYSTEM Page 1-4 1.2.2 Interactive Selection An interactive selection activates an image at the terminal. Possible interactive application programs are Datatrieve, an VAX/VMS based data entry/query program, and a backup procedure that asks questions. The format for the menu command is (note the ';' delimits parts): I;[;] Notice the three parts of the interactive command string, (1) 'I' interactive command code, (2) the command to execute, and (3) an optional comment. When the interactive selection is made, the main process sleeps until the subprocess completes the command. After completion, the menu is redisplayed and the menu system waits for another entry. 1.2.3 Message Display Selection The second type of selection is the message display. Simply, a message is displayed on the screen when the selection is chosen. The format of this menu command is: M; After the message is displayed, the menu system waits for the user to hit a return. When the return is depressed, the system clears the message , redisplays the 'RANGE' string and waits for another entry. 1.2.4 Display Another Menu The third type of selection is the one that allows you to display a new menu. Optionally, a one to six character password may be required; setting up for the password screen is described later. The menu to be displayed must be in the form library specified. The format of the display menu command is: D;[];[;] The password is case sensitive, if you enter it in lower case the user must enter it in lower case too. You can have many levels of menus. Think of these menus as different depths, somewhat like a family tree. The 'MAINMU' form is displayed as the highest depth. When a new menu is displayed, it is displayed at a lower depth. When a lower depth menu exits (depressing 0) it returns to the menu that requested it, at a higher depth. The maximum depth allowed by the menu system is 20 menus. MENU SYSTEM MENU SYSTEM Page 1-5 1.2.5 Submit A Batch Job The last type of menu selection command submits a batch job. It allows you to specify a particular queue for the batch job, or just default to SYS$BATCH. Furthermore, it allows you to run a interactive command to request input, before the batch command is submitted. The format of the batch menu command is: B;[;];<batch command>[;<queue>] The five parts provide for a flexible batch submission facility. The 'B' is the menu command code for a batch selection. Let's take a more detailed view of the other four parts. 1.2.5.1 Input Command - The optional input command is any DCL command you want to run interactively before the batch job gets started. You may want to enter selection criteria for a report or create a command file for the batch process to run later. The menu system changes your default directory to the directory that the batch job will be running. Then it executes the input command. Once completed, the menu system submits batch command and resets your default directory. 1.2.5.2 Title - The title is passed to the input command as a foreign command line. If the input command is a command file, you can get the title by using the P1 through P8 DCL symbols. If the input command is a program, you can get the title by calling the VOS routine GETCMD. 1.2.5.3 Batch Command - The batch command is a DCL command that gets executed in the batch process. It will execute in the directory the menu system has allocated for it. The batch command is responsible for cleaning up all of the files created in the default directory. 1.2.5.4 Queue - The batch command will execute in the specified queue or SYS$BATCH if queue is not specified. The batch queue should be one that is available from your computer node. MENU SYSTEM MENU SYSTEM Page 1-6 OPTIONAL NAMED DATA 1.3 OPTIONAL NAMED DATA Special named data elements not mentioned above are covered in detail here. The ENVIRONMENT named data item can change the way the selections and batch jobs run. The other three change the way the menu system acts to the user. 1.3.1 ENVIRONMENT The ENVIRONMENT named data specifies a command file to be executed before any selection or batch command. Be cautioned however, if you define logical names, the subprocess will keep the definitions until they are redefined. For example, if you define MY_FILE in an environment command file, MY_FILE will remain defined until it is deleted or you leave the menu. The menu system uses the ENVIRONMENT named data specified in the current menu screen. If one is not defined, no action is taken. 1.3.2 NO_RETURN The menu system allows the operator to see fatal error messages displayed by interactive programs before the menu is displayed over them. The NO_RETURN named data item, if defined in 'MAINMU', tells the menu system not to wait for the operator to hit a return after an interactive command. If this is not in the named data section the menu system retains screen context until a terminator is depressed. 1.3.3 NO_SUBMIT_MESSAGE The menu system, by default, displays the message the batch job controller returns when the submission is taken. This message includes the job name and job number. If the NO_SUBMIT_MESSAGE named data item is found in 'MAINMU' the menu system does not display this message and immediately redisplays the current menu. 1.3.4 NO_NOTIFY The menu system, by default, requests the batch job controller to notify the operator when a batch job is completed. If the NO_NOTIFY named data item is found in the menu 'MAINMU' the menu system skips this request. MENU SYSTEM MENU SYSTEM Page 1-7 VOS_BATCH_DISK: WHAT IS IT? 1.4 VOS_BATCH_DISK: WHAT IS IT? The batch jobs created by the menu system all execute in a directory allocated for it by the menu system. This keeps concurrently executing batch jobs from executing in the same directory and perhaps interfering with each other. These directories are of the form VOS_BATCH_DISK:[VOSBATCH.0000xx]. 1.4.1 Logical Name For this to work the logical name VOS_BATCH_DISK must be created and assigned to a disk the directories will be on. 1.4.2 Directories 51 directories must be created on VOS_BATCH_DISK. Each should have WO:RWE protection. The first is VOS_BATCH_DISK:[VOSBATCH]; this directory contains 50 subdirectories and the BATCHDIR.IDX file. The rest of the directories are subdirectories of [VOSBATCH] in the form [.0000xx] from [.000001] to [.000050]. 1.4.3 BATCHDIR.IDX The BATCHDIR.IDX file is used by the menu system to choose the next subdirectory for a batch job's current device and directory. The menu system increments the number from 1 to 50, and when it reaches 50 it changes it to 1 again to recycle through the directories. If 50 batch jobs will be running concurrently, or if a long job does not complete before 50 others, there can be a problem when next batch job runs. It will share the directory with the older batch job and the two jobs could disrupt each other. If this occurs the menu system should be modified to allow more directories, you could have up to 10000 if you really wanted. MENU HELP FACILITY 1.5 MENU HELP FACILITY The menu system has a help facility to provide user friendly guidance through your menus. When you depress the PF2(standard help) key, FMS tries to display some help information for the operator. With each depression of the PF2 key, the field help is displayed, then the form help is displayed, and finally the menu system help is displayed. If any one of the help does not exist, the next type is tried. For example, if there is no field help the first depression of the PF2 key displays the form help. MENU SYSTEM MENU SYSTEM Page 1-8 The menu system uses a post help user action routine (UAR) to give the third type of help. The third type is a menu that allows the operator to select a help screen to describe a particular selection on the menu. The help menu should look like the menu however a reverse video border or some other distraction around it should prevent operator confusion. There are a few steps that you must take to set up this facility. The steps are (1)link menu with help, (2) create the help menu, and (3) create the selection help screens. These are further described below. 1.5.1 Link Menu With Help FMS needs to be informed of this facility. The string "MENU_HELP" must be placed in the post-help UAR field in the form definition. This is done using the FMS form editor, in the FORM phase. 1.5.2 Create The Help Menu Make a copy of the menu form you would like to set up help for. Its name should be <original-name>_HELP.FRM. Use the FMS form editor to change the name of the form to match the form file name. Use the layout phase of the form editor and put a reverse video border around the screen to distinguish it from the menu screen. Use the named data phase of the form editor to change the named data items for the menu. Instead of menu control commands, each selection will have a help screen to be displayed when chosen. If you prefer not to create a help screen for a selection do not include it in the named data list. While in the named data phase of the form editor, make a change to the 'RANGE' named data item to better define what their selection will provide. 1.5.3 Create The Seletion Help Screens The help screens are restricted to one FMS form. Try to make it helpful, if not you are wasting their time. BATCH PRINT QUEUE --- VOS_BATCH_PRINT 1.6 BATCH PRINT QUEUE --- VOS_BATCH_PRINT The logical name VOS_BATCH_PRINT must be defined for in order MENU SYSTEM MENU SYSTEM Page 1-9 to submit a batch job using the menu system. It is assigned to a valid print queue that you want the batch logs to come out on. CAPTIVE MENU SYSTEM VOS_SLAVE_MENU 1.7 CAPTIVE MENU SYSTEM VOS_SLAVE_MENU If the logical name VOS_SLAVE_MENU is defined in the table LNM$JOB the menu system does not allow the operator to exit the 'MAINMU' screen. Combining this with a captive account allows you to set up captive menu systems. MENU SYSTEM MENU SYSTEM Page 1-10 1.8 MENU INTERNALS The MENU program is a utility that provides a friendly interface between humans and the computer system. A menu system is the menu program and a group of forms that describe possible actions. These FMS forms are maintained in a form library. Whenever a menu system is started the MAINMU form in the specified form library is displayed. When a selection is made, the named data item is retrieved corresponding with the number selected. The first letter in the named data string is the command. The rest of the string is split into different pieces of information and delimited by a semicolon. The rest of the named data gives more information for the command. There are four possible commands, (1) "D" for display a new menu, (2) "I" for execute a DCL command, (3) "M" for print a message on the terminal, and (4) "B" submit a batch job. 1.8.1 MENU Program - General Flow The general flow of the program is described in this section. The next page has a rough graphic illusration of how the program flows. The following pages describe each of the numbered boxes in more detail. The commands will be described in more detail in the next section. MENU SYSTEM MENU SYSTEM Page 1-11 MENU PROGRAM +-------------------+ | Parse command line| | and open library | +--------1----------+ | +-------------------+ | Spawn subprocess | | and start command | +--------2----------+ | +-------------------+ | Display MAINMU frm| |and check for menu | | directive namedata| +--------3----------+ | +-------------------+ | Loop while | | FORM_NUMBER GT 0 |-----------+ +-------------------+ | ^ +---------------+ | | Get input from| | | operator | | +------4--------+ | | | +---------------+ | |"PF4"-go back | +<---------------| to form 1 | | +------5--------+ | | | +---------------+ | |"0"-go back a | +<---------------| form | | +------6--------+ / | / +---------------+ / |get the command| / |for selection | / +------7--------+ / | | | | / +--- "M" ---+ "B" "I" +----- "D" -----+ / | / \ | / v v v v / +-----------+ +-----------+ +--------------+ +----------+ / |display a | |submit a | |execute an | |display a | | |message | |batch commd| |interactive | |new form | | +-----------+ +-----------+ +--------------+ +----------+ | | | | | | v v v v +<--------+<------------+<-------------+<--------------+ GENERAL FLOW OF MENU PROGRAM MENU SYSTEM MENU SYSTEM Page 1-12 The following elements describe the numbered boxes in the previous figure. 1. Parse command line and open library The menu program calls the runtime library routine LIB$GET_FOREIGN to get the command that the operator has entered or was entered for them. The expected syntax in the command string is: $ MENU <menu library file name> [<subprocess name>] The command line is parsed and the library and process name are saved. If they are not on the line, LIB$GET_FOREIGN is called again. This time however, only the library name is prompted for. The FMS routine FDV$LOPEN is used to open the library file. 2. Spawn subprocess and start command file Next we get the subprocess started. The first step is to create a temporary mailbox named MENU_MAILBOX. If the process name was filled in during the previous step, it is passed to LIB$SPAWN to create the subprocess. The mailbox is also passed to become the process permanent input device for the subprocess. Once the subprocess is created, we open the mailbox device and write the string "@VOS:[SHARED]SUBPROCESS.COM" to the mailbox for the subprocess to execute. This command file gets the commands from the menu program, executes them, and returns the status in a loop. 3. Display MAINMU form and check for menu directives To start a trip through FMS land, we must attach a workspace for the MAINMU form to be displayed. Then display the form within it. If the form does not get displayed because of an error, the menu program is crippled and must exit. When the program has to exit in this way, it also deletes the subprocess on the way out. There are three named data items that can control the menu program, these are (1) NO_RETURN, (2) NO_NOTIFY, and (3) NO_SUBMIT_MESSAGE. If NO_RETURN is defined in named data of MAINMU, the variable HIT_RETURN is set to false. If NO_NOTIFY is defined, NOTIFY_BATCH is set to false. And, if NO_SUBMIT_MESSAGE is defined, SUBMIT_MESSAGE is set to false. Once the MAINMU form is displayed, the FDV$RETDN (return named data by name) is called for each named data item. If the call is successful, the named data is defined - the value is not important. 4. Get input from operator MENU SYSTEM MENU SYSTEM Page 1-13 To get the input from the operator, we get the prompt from named data, display it and then get the input from the operator. The prompt string is kept in each form in the "RANGE" named data. The menu program gets that with the FDV$RETDN routine, clears out the "SELECT" field, and uses FDV$PUTL to display the prompt. The next step is to call FDV$GET to get the selection from the operator. 5. "PF4" - go back to form 1 If the operator depressed the "PF4" key, they want to return to the main menu. The "PF4" key is a field terminator. The terminator argument of the FDV$GET call contains the value FDV$K_PF_4 if they depress the key. If the "PF4" key is depressed the menu system loops back through the WORKSPACE array and detaches all of the workspaces except the first and decrementing FORM_NUMBER along the way. After they are all detached, the first workspace (MAINMU's) is set as the default and it is redisplayed. 6. "0" - Go back one menu form If the operator presses the "0" key, the menu program must display the menu that was displayed before this menu. First, detach the current workspace, using the FDV$DWKSP routine. Second, decrease the FORM_NUMBER variable by one. And third, set the default workspace to be the current one and display it. If the FORM_NUMBER equals 1 and we are not slave, the workspace is detached and the FORM_NUMBER is decremented. The presence of the logical name VOS_SLAVE_MENU in the job logical name table makes this processes' menu program slave. This throws us out of the loop and causes the menu program to exit. On the other hand if we are slave, the menu program ignores this request to exit. 7. Get the command for the valid selection If we have made it this far, the entry made by the operator is valid or the menu program is going to ignore it. The routine FDV$RETDN is called using the value entered by the operator. The named data is returned and further control is decided by the first character of the named data string. The next section gives more information about what is done for each type of command. 1.8.2 Commands MENU SYSTEM MENU SYSTEM Page 1-14 1.8.2.1 The "D" Command - "D;[<password>];<new Menu Form Name>;" The "D" command displays a new menu screen. The first parameter is the password to use. If this parameter is non-null, the "PASWRD" form, performs a FDV$GET on the field "PASSWD" and matches the string received with the parameter. If there is a match or if the password parameter is a null string, the next parameter is used as a form name to display. To display a new form, them menu program must take 4 steps. The first step is to increase the form number by one, there can be up to 20, this is our menu depth indicator. Then the form name is saved in the FORM_NAME array so we know which one we are working on now. The third step is to attach a FMS workspace to display the current form. The previous form's workspace is left intact. The last is to display the form in the workspace. This technique allows the menu program to go back one level (when they enter "0") by changing default workspaces and displaying the form that is in the workspace. 1.8.2.2 The "I" Command - "I;<valid DCL Command>" - The "I" command executes an interactive DCL command in the subprocess. The DCL command is parsed out of the named data string. The environment command file is executed in the subprocess if there is one specified. The command is written to the mailbox which already has a read posted on it from the subprocess. Then the menu program posts a read on the mailbox lun to receive the completion status. After the completion status is returned, the corresponding error message is printed out if the HIT_RETURN is true. This message is printed out once the menu is redisplayed. 1.8.2.3 The "M" Command - "M;<any Message>" - The "M" command displays a message to the screen. The message is parsed from the named data and the FDV$PUTL routine is used to display it on the screen. The operator is then signaled and the menu program waits for the operator to press return. No change is made to the menu currently displayed. 1.8.2.4 The "B" Command - - "B;[<DCL interactive >;<title>];<Batch command>;[<Batch queue>]" The "B" command submits a batch job for the operator. This command is the most complicated. It also allows you to execute an interactive command with the same default directory as the batch job. The batch command can be controlled by the context defined MENU SYSTEM MENU SYSTEM Page 1-15 by the interactive command. The subroutine SUBMIT_BATCH_JOB does the work for the "B" command. The named data is parsed to get the different parameters. If the DCL command parameter is blank, then there is no title and the parsed parameter values are off by one. The parameter values are updated accordingly in that event. The next step is to get the next available directory using the GET_DIRECTORY subroutine. This directory will be used as the default directory for the DCL command and the batch job. If the command is non-blank then we write three strings to the subprocess, (1) write the SET DEFAULT string to change the default directory to the one we got from GET_DIRECTORY, (2) call the SET_UP_ENVIRONMENT to execute an environment command if specified and (3) write the DCL command. IF THE STATUS RETURNED FROM THE DCL COMMAND IS NOT ODD, THE REST OF THESE STEPS ARE SKIPPED AND THE MENU IS REDISPLAYED. This feature allows the interative part to control whether the batch job is run. There may be insufficient data or the operator changed its mind. Once the interactive command has executed successfully, we need to create the batch procedure that will execute their batch command. The following things are put in the batch procedure: o $ SET DEFAULT VOS_BATCH_DISK:[VOSBATCH.xxxxxx] This command sets the default directory for the batch process to the one that was selected earlier. This is the directory that the DCL command ran in. o $ <environment command> The environment command is returned from the ENVIRONMENT named data. The current menu form is used to get the value. The command is put into the batch procedure without any translation. o $ <batch command> The batch command is the one from our selection. It is put into the batch procedure without translation. o $ EXIT The exit command is put into the batch procedure for completeness The next step is to submit the batch procedure. All of the arguments are checked to make sure they are non-blank. For example, if the batch queue was not specified, batch queue is filled with the SYS$BATCH queue name. The item list for the MENU SYSTEM MENU SYSTEM Page 1-16 SYS$SNDJBC, send job controller message, is filled in with all of the arguments and system service is called. If it failed the error message corresponding to the problem is displayed on the screen. Otherwise, if the NO_SUBMIT_MESSAGE named data exists (found this while initializing menu program) then no job status string is displayed to show success. If it did not exist, it would be displayed. 1.8.3 MENU From VMS's Point Of View The menu program executes in the process that types the MENU command. Nothing but the menu can run in this process. The menu program creates a subprocess using the LIB$SPAWN run-time library routine to execute any commands or images that are called for. The main program handles "M"essage commands and "D"isplay a new menu commands without the subprocess being involved. The menu program does the submission of the batch job. The subprocess handles the "I"nteractive command and the DCL interactive command part of the "B"atch command. The menu program creates a mailbox that is used for interprocess communication to/from the subprocess. The mailbox is defined as the subprocesses process permanent SYS$INPUT file. The menu program first tells the subprocess to run VOS:[SHARED]SUBPROCESS.COM by writing "@" and the file name to the mailbox. The subprocess command file opens the mailbox for read and write access and posts a read waiting for the next command. When it gets one it executes it and writes the severity code back to the menu program via the mailbox. Once the subprocess command file is running, all further interaction can be shown using the following figure. MENU SYSTEM MENU SYSTEM Page 1-17 $ MENU MENULIBRARY.FLB HARPO your process subprocess HARPO running:MENU.EXE @SUBPROCESS.COM -----------------+ +------------------ a selection is | |commands from main made and command\ / process are read sent |\ /| and executed | \------------->/ | . | ____________ | . | | mailbox | | | |__________| | | | | /<-------------\ | |/ \| / \ go get another | | return the severity selection | | to menu program -----------------+ +------------------ COMMUNICATION BETWEEN MENU PROGRAM AND SUBPROCESS MENU SYSTEM MENU SYSTEM Page 1-18