Previous | Contents | Index |
You might want to display the menu to the user with the highlight bar already positioned on an often used menu item. If the user wants that item, they can simply press [Return]. Otherwise, they can backup to previous menu(s) or use the arrows keys to select another menu item.
INTOUCH allows you to set up a default menu item by using the DEFAULT option of INPUT.
In the following example, the default is the fourth item of the first menu and the second item of the submenu. The default item can be as deep as there are existing menu levels.
1 program application_3_8 10 clear 20 sample_menu$ = '%width 12, %menubar, %autovbar on,' & + 'add, change, delete, inquire = {product, customer, sales}' 30 input menu sample_menu$, default '#4;#2': selection$ print 'Default was CUSTOMER, selected menu item was: '; selection$ 40 end |
+------------------------------------------------------------------------------+ | ADD | CHANGE | DELETE | INQUIRE | +------------------------------------------+---INQUIRE---+---------------------+ | PRODUCT | | CUSTOMER | | SALES | +-------------+ Default was CUSTOMER, selected menu item was: CUSTOMER |
After a user selects a menu item, some processing is performed. When the the processing steps are completed, the menu can be redisplayed and the user can make the next selection. To get back to the menu and display the previous selection, you use the DEFAULT option with _string qualifier. _string contains the last menu selection.
If you are doing more than one menu sequence, you will need to save earlier _string values in string variables. These variables can then be used with the DEFAULT option to take you back into a particular menu sequence at any given time.
The following example shows how to display a menu, do some processing and return to the previously selected menu option.
1 program application_3_9 10 clear 20 sample_menu$ = '%width 12, %menubar, %autovbar on,' & + 'add, change, delete, inquire, exit' 30 input menu sample_menu$ : selection$ 40 do clear if _exit then exit do print 'The menu selection was: '; selection$ print 'You will now do some '; selection$; ' processing....' print print 'When you press RETURN, the previous menu and selection '; & 'will be displayed. You can select another menu option'; & 'or select the EXIT option to end this program' print input prompt '': z$ clear input menu sample_menu$, default _string: selection$ loop 50 end |
The menu is displayed:
+------------------------------------------------------------------------------+ | ADD | CHANGE | DELETE | INQUIRE | EXIT | +------------------------------------------------------------------------------+ |
If the user selects the CHANGE item, this message information is displayed:
The menu selection was: CHANGE You will now do some CHANGE processing.... When you press RETURN, the previous menu and selection will be displayed. You can select another menu option or select the EXIT option to end this program |
When the user presses [Return], the menu will be redisplayed and will show the previous menu selection.
+------------------------------------------------------------------------------+ | ADD | CHANGE | DELETE | INQUIRE | EXIT | +------------------------------------------------------------------------------+ |
When a user selects a menu item, the selected menu item is stored in the specified variable, i.e. SELECTION$. For example, if the user selected the menu item "Add New Customers", SELECTION$ would contain "Add New Customers". To make SELECTION$ contain something shorter, such as the word "ADD", you can assign a value to the menu item.
To assign a value to the menu item, add an equal sign (=) and a value to the menu item element.
The following example shows you how to assign values.
1 program application_3_10 10 clear 20 master_menu$ = '%at 2, 10, %title "Master Menu",' & + '%heading "Procedures","Add New Customers" = ADD,' & + '"Change Customer Data" = CHA,' & + '"Delete Customers" = DEL, "Customer Inquiry" = INQ,' & + '%heading "Other Options","Mail" = MAIL,' & + '"Help", "Exit"' 30 line input menu master_menu$: selection$ 40 print at 21,1 : 'The menu selection was: '; selection$ 50 end |
+-------Master Menu-------+ | | | Procedures | | Add New Customers | | Change Customer Data | | Delete Customers | | Customer Inquiry | | | | Other Options | | Mail | | Help | | Exit | +-------------------------+ The menu selection was: CHA |
Messages can be used to give the user specific input instructions, highlight input errors and provide information. Messages can be used in place of print statements.
INTOUCH messages are displayed in bold and centered one line above the bottom line of the screen (i.e. line 23 of a 24-line screen). If the INTOUCH screen frame is on, the message is embedded in the bottom portion of the screen frame.
A message can be up to 80 characters in length.
The examples in this chapter are run with the INTOUCH screen frame ON. |
4.1 Message Types
There are basically three types of messages and three INTOUCH
statements to display the messages. The INTOUCH statements are:
The following example illustrates the three ways to use messages.
1 program application_4_1 10 clear print at 2, 20, bold, reverse: 'Examples of Message Usage' print 20 message 'Enter the date in the format YYYYMMDD' do input 'Current date', at 4,1: answer$ if answer$ = date$ then message delay: 'That is the correct date' exit do else message error: 'Incorrect date' clear area 4,1,4,80 repeat do end if loop 30 message '' clear 40 end |
?10pc This is an example of an instructional message:
Examples of Message Usage Current date? Enter the date in the format YYYYMMDD EXIT = Exit \ = Back HELP = Help |
?10pc This is an example of an error message:
Examples of Message Usage Current date? 19960211 Incorrect date EXIT = Exit \ = Back HELP = Help |
?10pc This is an example of a delayed message:
Examples of Message Usage Current date? 19960513 That is the correct date EXIT = Exit \ = Back HELP = Help |
Depending on the type of terminal, the number of screen lines or rows can vary. For example, VT style terminals usually have 24 screen lines on a page, but other types of terminals might have more or less than 24. On some terminals, you can even set the number of screen lines per page. To find out what the page size is, you can use the ASK PAGESIZE statement.
If you do not want to display messages on the normal message line, INTOUCH allows you to control message placement by using the ASK MESSAGELINE and SET MESSAGELINE statements.
?10pc
This example shows you how to change the message line number.
1 program application_4_2 10 clear print at 1,1:; ask system: user uname$ ask pagesize lines message 'Hello...'; uname$ delay 2 20 ask messageline orig_mess_line 30 do print at 2,1: 'Total screen lines (page size) is'; lines input 'Enter a new message line number from 1 to total lines', & at 4, 1: new_line if _back or _exit or new_line = 0 then exit do clear set messageline new_line message 'The messages will now be displayed on line '; new_line delay 3 message 'Enter another number or enter EXIT to exit' loop 40 message 'The original message line will reset in a few seconds...' delay 3 set messageline orig_mess_line message 'The message line has been reset to its original position' 50 end |
Total screen lines (page size) is 24 Enter a new message line number from 1 to total lines? 12 Hello...FRED EXIT = Exit \ = Back HELP = Help |
Total screen lines (page size) is 24 Enter a new message line number from 1 to total lines? (line 12) Enter another number or enter EXIT to exit |
There are times when you want to delay a program to make the user aware of specific actions or display some pertinent information. You can use the DELAY statement to stop the program and allow the user to continue when they are ready.
1 program application_4_3 10 clear 20 print bold, at 3,15 : 'SUMMARY TOTALS' print at 5,5 : 'Beginning Balance: 245,234.69' print at 7,5 : 'Activity Today : 89,267.05' print at 9,5 : 'Ending Balance : 334,501.74' print at 12,5 : 'Orders Processed : 68' print bold, at 16,20 : 'Sales Files will now be updated...' 30 delay clear 40 end |
SUMMARY TOTALS Beginning Balance: 245,234.69 Activity Today : 89,267.05 Ending Balance : 334,501.74 Orders Processed : 68 Sales Files will now be updated... Press the RETURN key to continue EXIT = Exit \ = Back HELP = Help |
When a user responds to a prompt, they usually type in some data or select a menu item and then press the [Return] key to signal the end of their response. However, the user might, instead, press a specific key (i.e. \, [Help] key, etc.) or keys (i.e. [Ctrl/Z]) and that is their response. As you can see, an application routine must first determine if the user actually entered some data or requested a specific action and then, either validate the data or perform the action. To assist in deciphering a response, INTOUCH provides numerous built-in functions which analyze the response and make it easy for the programmer to determine what a user entered.
INTOUCH processes a response as two separate parts. One part is the reply (i.e typed data or nothing) and the other part is the terminator (\, [Return], [Help], etc.). INTOUCH stores the reply and the terminator in the internal variables _REPLY (see Section 5.1) and _TERMINATOR (see Section 5.2). INTOUCH also analyzes the terminator and, depending on its contents, sets other internal variables to TRUE or FALSE. The programmer can then check the internal variables and take the appropriate action. For example, if the internal variable _EXIT is TRUE, you know the user either entered "EXIT" or [Ctrl/Z].
This chapter contains information on some of the commonly used INTOUCH system functions and internal variables. The appendix section of the INTOUCH - A Guide to the Language manual contains information on all the system and other built-in functions and internal variables.
In INTOUCH, the concepts of backing up, exiting, getting help, etc. are assigned to specific keys. For example, if you are at the OpenVMS $ prompt and press the \ (backslash) key, nothing happens. But, if you are in an INTOUCH program and you press the \ key, you will back up to a previous prompt or menu. This occurs because INTOUCH has assigned the concept of backing up as the default value for the \ key.
When you are in INTOUCH, you can change the current key values to other values or no value at all (see Section 5.4). For example, the \ key does not have to default to backing up. You can change the value of the "B" key or any other key to default to backing up and the \ key can be changed to another value or no value at all.
5.1 Checking _REPLY
One of INTOUCH's system functions always stores the
last user entered input (in string format) in
_REPLY. This internal variable provides you with a
generic place to store the user's last reply, and it becomes specially
useful when debugging.
The keystroke that terminated the last user input is stored in the internal variable, _TERMINATOR.
INTOUCH processes a response in this manner:
Entered response _REPLY contains _TERMINATOR contains ------------------ --------------- -------------------- SMITH (Return key) SMITH RETURN Smith (Return key) Smith RETURN 25.00 (Return key) 25.00 RETURN (Return key) null value RETURN (Help key) null value HELP 25.00\ null value \ 25.00 (Ctrl/Z) null value CTRL/Z |
1 program application_5_1 10 clear 20 line input 'Add this customer record (Y/N)': answer$ print print 'The reply was : '; _reply print 'The terminator was: '; _terminator print 30 line input 'Type your name and then press the "\" key': answer$ print print 'The reply was : '; _reply print 'The terminator was: '; _terminator 40 end |
Add this customer record (Y/N)? yes The reply was : yes The terminator was: RETURN Type your name and then press the "\" key? tester\ The reply was : The terminator was: \ |
The concept of terminating input defaults to various (normally) non-character keys such as the [Return] key, arrow keys, \, [Help] key, etc. For example, when a user responds to a prompt, they either enter some data and press [Return] or they enter \ to back up, [Help] to get help, etc. Whatever keystroke terminates the input is the input terminator and INTOUCH stores this terminator in the _TERMINATOR internal variable.
You can check the _TERMINATOR variable to find out what keystroke terminated the last input. You can also change any of the default terminating keys to other keys. (See Section 5.4.)
The following is just a few of the non-character keys that can be checked. A complete list can be found in the INTOUCH - A Guide to the Language manual.
1 program application_5_2 10 clear 20 input prompt 'Press the up arrow, down arrow or RETURN key': answer$ 30 print if _terminator = 'UP' or _terminator = 'DOWN' then print 'The '; _terminator; ' arrow key was pressed' else print 'The '; _terminator; ' key was pressed' end if 40 end |
Press the up arrow, down arrow or RETURN key The DOWN arrow key was pressed |
Previous | Next | Contents | Index |