INTOUCH® 4GL
Application Development Guide


Previous Contents Index

Chapter 3
Creating Menus

Menus are another form of input and are often favored by users because they require the least amount of effort. The user simply uses the arrow keys to select the menu item and then presses the [Return] key. INTOUCH makes working with menus quick and easy with the MENU option of the INPUT and LINE INPUT statements.

An INTOUCH menu is comprised of comma-separated elements. These elements can either be menu selection items (items on the menu the user selects from) or directives (menu presentation instructions). Each menu item can call a submenu and the submenu items can also call submenus. The directives can be used to customize your menus (i.e. give the menu a title, headings, screen placement, etc).

A menu can contain an unlimited number of items because the screen scrolls up and down between the items or left and right for a horizontal (bar) menu. Unless otherwise specified, INTOUCH automatically determines menu positioning on the screen, menu width and centering of all titles.

3.1 Menu Composition

A menu can consist of a single string literal containing directives and menu items, such as:


        1   program application_3_1 
        10  clear 
            the_menu$ = '%title "Animals", dog, cat, horse' 
            input menu the_menu$ : answer$ 
        20  end 



                  +-Animals--+ 
                  |  DOG     | 
                  |  CAT     | 
                  |  HORSE   | 
                  +----------+ 

Menus can consist of string variables which contain directives and menu items, such as:


        10  the_title$ = '%title "The Animals",' 
            the_items$ = 'dog, cat, horse' 
        20  the_menu$ = the_title$ + the_items$ 
            input menu the_menu$ : answer$ 
    or 
        20  the_menu$ = the_title$ & the_items$ 
            input menu the_menu$ : answer$ 

The + sign and the & are interchangeable. The elements must be separated by commas.

Menus can consist of directives and string variables and literals, such as:


        10  the_items$ = 'dog, cat, horse,' 
            the_menu$ = '%title "Animals",' + the_items$ + 'mouse' 
            input menu the_menu$ : answer$ 

Menus can also consist of record fields and input data. An example using record data is included in the menu example section.

3.2 Hints for Creating Menus

A menu or part of a menu that consists of a string literal, is enclosed within quotes. Either the single quote (') or the double quote mark (") can be used. The menu elements (directives and items) are separated by commas. For example:


                beginning quote                 ending quote 
                        |                                 | 
                        v                                 v 
        10  the_menu$ = '%title "Animals", dog, cat, horse' 
                            ^               ^    ^     ^ 
                            |               |    |     | 
                        directive            menu items 
                            |                    | 
                            +------elements------+ 

If the menu items contain spaces or special characters, they MUST be enclosed within quotes. For example:


        10  the_menu$ = '"the dog", "the cat", "the horse"' 

INTOUCH will UPPERCASE menu items that are not enclosed in quotes. If your menu items contain upper and lower case characters and you want them displayed that way, you will need to enclose them in quotes.

The menu directives are just another element in the menu string. They are preceeded by a "%" and followed by a comma. For example:


        10  the_menu$ = '%title "Animals", "the dog", "the cat", "the horse"' 

If the menu is longer than one line, you can continue on the next line in this way:


        10  the_menu$ = '%title "Animals", "the dog", "the cat", "the horse"' & 
                        + '"the cow", "the pig"' 
    or in this way: 
 
        10  the_menu$ = '%title "Animals", "the dog", "the cat", "the horse"' + & 
                        '"the cow", "the pig"' 

Use INPUT MENU if your menu item selections contain one word elements (no spaces or special characters) otherwise, use LINE INPUT MENU. For example:


        10  the_menu$ = 'dog, cat, horse' 
        20  input menu the_menu$ : answer$ 
 
        10  the_menu$ = '"the dog", "the cat", "the horse"' 
        20  line input menu the_menu$ : answer$ 

If your menu contains an "EXIT", "HELP" or other system function element and the user selects this element, _EXIT, _HELP, etc. are set to TRUE and the input variable (i.e. answer$) will be a null.

3.3 Using Menus

Using INTOUCH menus is similar to other applications in that the [Return] key, ARROW keys and BACKSLASH (\) key are used. To select menu items:

3.4 Menu Examples

The following menu examples will show how to create simple to more complex menus which can be used for different applications. The directives will be described as they are used.

Example 1

This is an example of a common type of menu that would be created for user input.


        1   program application_3_2 
        10  clear 
        20  sort_selections$ = '%title "Sort Selections", "Account",' & 
                + '"Division", "Name", "State"' 
        30  input menu sort_selections$: selection$ 
        40  print 'The menu selection was:  '; selection$ 
        50  end 



 
          +Sort Selections+ 
          |  Account      | 
          |  Division     | 
          |  Name         | 
          |  State        | 
          +---------------+ 
 
 
The menu selection was:  Division 
 

The directive used in this menu example was:

Example 2

This is an example of a master or main menu which is used as a starting point in many applications.


        1   program application_3_3 
        10  clear 
        20  master_menu$ = '%at 2, 10, %title "Master Menu",' & 
                + '%heading "Procedures","Add New Customers",' & 
                + '"Change Customer Data",' & 
                + '"Delete Customers","Customer Inquiry",' & 
                + '%heading "Other Options","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:  Change Customer Data 
 

The directives used in this menu example are:

Example 3

This is an example of a menu with submenus and a submenu which has a submenu.


        1   program application_3_4 
        10  clear 
        20  customer_data$ = '%title "Customer Data", "Account",' & 
                + '"Name" = {"First", "Middle", "Last"},' & 
                + '"Address" = {"Street", "City", "State", "Zip Code",' & 
                + '"Country" = {"United States", "Foreign"}},' & 
                + '"Phone", "Extension", "Division", "Cost Center", "Contact"' 
        30  line input menu customer_data$: selection$ 
        40  print at 21,1 : 'The menu selection was:  '; selection$ 
        50  end 

The first menu is displayed. The [> to the right of the menu item indicates that there are options for this menu item.



 
  +-Customer Data--+ 
  |  Account       | 
  |  Name        [>| 
  |  Address     [>| 
  |  Phone         | 
  |  Extension     | 
  |  Division      | 
  |  Cost Center   | 
  |  Contact       | 
  +----------------+ 
 

If the user selects the Name item, the following is displayed:



 
  +-Customer Data--+ 
  |  Account     +---Name----+ 
  |  Name        |  First    | 
  |  Address     |  Middle   | 
  |  Phone       |  Last     | 
  |  Extension   +-----------+ 
  |  Division      | 
  |  Cost Center   | 
  |  Contact       | 
  +----------------+ 
 
 
The menu selection was:  Middle 
 

If the user selects the Address item and the Country item, the following is displayed:



  +-Customer Data--+ 
  |  Account       | 
  |  Name        +---Address---+ 
  |  Address     |  Street     | 
  |  Phone       |  City       | 
  |  Extension   |  State      | 
  |  Division    |  Zip Code +-----Country------+ 
  |  Cost Center |  Country  |  United States   | 
  |  Contact     +-----------|  Foreign         | 
  +----------------+         +------------------+ 
 
 
The menu selection was:  Foreign 
 

The directives used in this menu example are:

Example 4

This is an example of a horizontal menu with pull-down submenus.


        1   program application_3_5 
        10  clear 
        20  customer_data$ = '%menubar, %autovbar on, %autodisplay off,' & 
                + '"Account",' & 
                + '"Name" = {%title "", "First", "Middle", "Last"},' & 
                + '"Address" = {%title "", "Street", "City", "State",' & 
                + ' "Zip Code",' & 
                + '"Country" = {"United States", "Foreign"}},' & 
                + '"Phone", "Extension", "Division", "Cost Center", "Contact"' 
        30  line input menu customer_data$: selection$ 
            print at 21,1 : 'The menu selection was:  '; selection$ 
        40  end 

When the program is run, the bar menu is displayed:



 
+------------------------------------------------------------------------------+
|  Account   |   Name   |   Address   |   Phone   |   Extension              >>|
+------------------------------------------------------------------------------+
 

The >> indicates that there are more menu items but there was not room to display them on the screen. If you arrow to the right to display the items, there will be << on the left side.

If you select the "Address" item, the address submenu is displayed. If "Country" is selected, the country submenu is displayed.



 
+------------------------------------------------------------------------------+
|  Account   |   Name   |   Address   |   Phone   |   Extension              >>|
+-------------------------+-------------+--------------------------------------+
                          |  Street     |
                          |  City       |
                          |  State      |
                          |  Zip Code +-----Country------+
                          |  Country  |  United States   |
                          +-----------|  Foreign         |
                                      +------------------+
 
 
The menu selection was:  Foreign 
 

The directives used in this menu example are:

The %title option with no title was used to suppress the title in the pull-down menus.

In this example the automatic display of the pull-down submenus was turned off. This requires a user to enter more keystrokes than if the submenus are displayed automatically.

Example 5

In this example, the first menu is displayed. After the user makes a selection, the first menu is erased and a submenu is displayed. The user is able to select multiple items from the submenu. To select multiple items, use the arrow keys to make a selection and then press the [Select] key or the [SPACE BAR]. This can be done repeatedly. After all the items have been selected, press the [Return] key.

The submenus are examples of menu items listed in columns.


        1   program application_3_6 
        10  clear 
        20  domestic$ = 'DOMESTIC = {%replace, %columns 3, %width 15,' & 
                + '%at 4, 10, %multi, %title "SELECT DOMESTIC CARS", BLAZER,' & 
                + 'BRONCO, BUICK, CADILLAC, CORVETTE, LINCOLN, MUSTANG,' & 
                + 'MERCURY, THUNDERBIRD},' 
        30  foreign$ = 'FOREIGN = {%replace, %columns 2, %width 15,' & 
                + '%at 4, 10, %multi, %title "SELECT FOREIGN CARS", ACURA,' & 
                + 'HONDA, INFINITY, LEXUS, MAZDA, MITSUBISHI, NISSAN, SUZUKI,' & 
                + 'SUBARU, TOYOTA, %bar, HYUNDAI, YUGO, %bar, AUDI,' & 
                + 'VOLKSWAGON}' 
        40  car_menu$ = '%title "Car Category",' & domestic$ & foreign$ 
        50  input menu car_menu$: selection$ 
        60  print 'Number of selections: '; pieces(selection$, chr$(10)) 
            print 'The selected items are: '; selection$ 
        70  end 

The first screen is displayed.



 
    +Car Category-+ 
    |  DOMESTIC ..| 
    |  FOREIGN... | 
    +-------------+ 
 

If the user selects DOMESTIC, the following menu will be displayed. Whatever items are selected by the user will be underlined.



 
         +---------------SELECT DOMESTIC CARS---------------+ 
         |  BLAZER       |   CADILLAC     |   MUSTANG       | 
         |  BRONCO       |   CORVETTE     |   MERCURY       | 
         |  BUICK        |   LINCOLN      |   THUNDERBIRD   | 
         +--------------------------------------------------+ 
 
Number of selections:  3 
The selected items are: BLAZER 
                              CORVETTE 
                                      THUNDERBIRD 
 

If the user selects FOREIGN, the following menu will be displayed. Whatever items are selected by the user will be underlined.



 
         +------SELECT FOREIGN CARS-------+ 
         |  ACURA        |   SUBARU       | 
         |  HONDA        |   TOYOTA       | 
         |  INFINITY     | ---------------| 
         |  LEXUS        |   HYUNDAI      | 
         |  MAZDA        |   YUGO         | 
         |  MITSUBISHI   | ---------------| 
         |  NISSAN       |   AUDI         | 
         |  SUZUKI       |   VOLKSWAGON   | 
         +--------------------------------+ 
 
 
Number of selections:  4 
The selected items are: INFINITY 
                                SUBARU 
                                      HYUNDAI 
                                             VOLKSWAGON 

The directives used in this menu example are:

Example 6

This example shows how to create a menu using field data from a file. In this case, the data in the CLIENT file becomes the menu item selections.


        1   program application_3_7 
        10  clear 
            the_menu$ = '%title "Select a Client", %at 3,20' 
        20  open structure cl : name 'tti_run:client' 
            extract structure cl 
              sort by cl(last) 
            end extract 
            for each cl 
              the_menu$ = the_menu$ + ',' + cl(last) 
            next cl 
            close structure cl 
        30  input menu the_menu$ : answer$ 
            print 'The menu selection was:  '; answer$ 
        40  end 

The program creates the menu items using the last names in the CLIENT file records.



 
                   +Select a Client+ 
                   |  ABOTT        | 
                   |  BROCK        | 
                   |  CASS         | 
                   |  DERRINGER    | 
                   |  DONALDSON    | 
                   |  ERRANT       | 
                   |  FARMER       | 
                   |  JOHNSON      | 
                   |  JONES        | 
                   |  KENT         | 
                   |  PORTER       | 
                   |  RODRIGUES    | 
                   |  SMITH        | 
                   |  WATERS       | 
                   +---------------+ 
 
 
The menu selection was:  JOHNSON 
 

The directives used in this menu example are:

3.5 Menu Directives

The menu examples used some of the menu directives. The following is a list of all the available menu directives. The INTOUCH - Guide to the Language manual explains each of these directives in detail.

Table 3-1 Menu Directives
%at row,column positions the menu
%autodisplay off disables the automatic display of submenus
%autovbar on|off ON prints a vertical bar between each of the menu items in a bar menu; OFF prints no vertical bars; the default is OFF
%bar ["..."] used to separate menu items; if no text is supplied, a dashed line will be displayed
%columns n sets the number of columns for the menu
%heading ["..."] displays a blank line and a text string between menu items; if no text is provided, a blank line and a dashed line are displayed
%items n creates a multi-column menu
%lockstep on|off controls scrolling for multi-columned menus; normally the columns scroll together, OFF causes the columns to scroll independently; the default is ON
%maxwidth n controls the maximum width of the entire menu
%menubar displays the menu horizontally; this is a bar menu
%message displays a message when the menu is displayed
%multi allows multiple menu items to be selected
%replace used in submenus to erase the calling menu; \ will redisplay the calling menu
%size n determines the number of menu items in the menu box
%split starts a new column at this point in the menu
%title "..." gives the menu or submenu a title
%vbar used to insert a vertical bar between two menu items in a bar menu
%width n controls the minimum width of the current column


Previous Next Contents Index