table menu ...

Prev Next

Function Names

table menu, table menu quick

Description

This function provides a menu on the console allowing user to select a choice. table menu supports input choices containing 1 or more characters which need to be typed in and confirmed with pressing [Enter]. Input is case sensitive. In case a wrong selection is entered, you will be asked to repeat the choice. You can stop running the program by just entering a blank line by pressing [Enter] only.

table menu quick supports input choices containing exactly 1 character which will be accepted without need to press [Enter]. The input is not case sensitive. Execution continus immediately if a right choice is entered. In addition, The user can stop the program with Escape or Control-C.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

4

Parameters

No.TypeDescription
1.
input
string Name of existing table

2
input
table column Input choices

Specify the input the user needs to enter to choose the item. For table menu quick, limit to 1 character.

See table columns as function parameters for general ruling for this parameter.
Specific rules apply for this function:

  • Exactly 1 header names or column numbers may be specified

3
input
table column Description column

The description items in the table will be shown when the menu is displayed.

See table columns as function parameters for general ruling for this parameter.
Specific rules apply for this function:

  • Exactly 1 header names or column numbers may be specified

4
input
table column Selection column

The corresponding selection value will be returned after the user has entered the choice.

See table columns as function parameters for general ruling for this parameter.
Specific rules apply for this function:

  • Exactly 1 header names or column numbers may be specified

Return value

TypeDescription
string Returned selection

The selection is the corresponding entry from the selection column in the table.

Examples

  table initialize ( menu,
      { { Choice, Description, Selection, Wine },
        { A,      Smoked salmon with cherry tomatoes,  Fish,  Chablais },
        { B,      300g sirloin with baked potatoes, Beef, Cabernet Sauvignon },
        { C,      Chicken brest with red curry, Riesling },
        { D,      Tirami sù, Dessert, Vin Santo } });

  chosen[] = table menu quick( menu, Choice, Description, Selection );

  echo("You have chosen ", chosen[] );
  echo("We recommend the following wine: ", [menu:Selection,chosen[],Wine] );

Output

    A :  Smoked salmon with cherry tomatoes
    B :  300g sirloin with baked potatoes
    C :  Chicken brest with red curry
    D :  Tirami sù
Please select: B
You have chosen Beef
We recommend the following wine: Cabernet Sauvignon
Try it yourself: Open LIB_Function_table_menu.b4p in B4P_Examples.zip. Decompress before use.

See also

input
input quick