# __MenuTo()

Invoked a menu defined by set of @...PROMPT

Syntax

  __MenuTo( <bBlock>, <cVariable> ) --> nChoice

Arguments

  <bBlock> is a set/get code block for variable named <cVariable>.
  <cVariable> is a character string that contain the name of the variable to hold the menu choices, if this variable does not exist a PRIVATE variable with the name <cVariable> would be created to hold the result.

Returns

  __MenuTo() return the number of select menu item, or 0 if there was no item to select from or if the user pressed the Esc key.

Description

  __MenuTo() invoked the menu define by previous __AtPrompt() call and display a highlight bar that the user can move to select an option from the menu. If <cVariable> does not exist or not visible, a PRIVATE variable named <cVariable> is created and hold the current menu selection. If there is a variable named <cVariable>, its value is used to select the first highlighted item.
  Menu prompts and messages are displayed in current Standard color, highlighted bar is displayed using current Enhanced color.
  Pressing the arrow keys move the highlighted bar. When a menu item is highlighted the message associated with it is displayed on the line specified with SET MESSAGE. If SET WRAP is ON and the user press UP arrow while on the first selection the last menu item is highlighted, if the user press Down arrow while on the last item, the first item is highlighted.
  Following are active keys that handled by __MenuTo(): -----------------------------------------------------

key | Meaning
Up | Move to previous item
Down | Move to next item
Left | Move to previous item
Right | Move to next item
Home | Move to the first item
End | Move to the last item
Page-Up | Select menu item, return position
Page-Down | Select menu item, return position
Enter | Select menu item, return position
Esc | Abort selection, return 0
First letter | Select next menu with the same first letter,
| | return this item position.

  upon exit the cursor is placed at MAXROW()-1, 0 __MenuTo() can be nested without loosing the previous prompts.
  MENU TO command is preprocessed into __MenuTo() function during compile time.

Examples

          // display menu item on each screen corner and let user select one
          CLS
          SET MESSAGE TO MAXROW()/2 CENTER
          SET WRAP ON
          @ 0,         0           PROMPT "1. Upper left"   MESSAGE " One "
          @ 0,         MAXCOL()-16 PROMPT "2. Upper right"  MESSAGE " Two "
          @ MAXROW()-1,MAXCOL()-16 PROMPT "3. Bottom right" MESSAGE "Three"
          @ MAXROW()-1,0           PROMPT "4. Bottom left"  MESSAGE "Four "
          MENU TO nChoice
          SETPOS ( MAXROW()/2, MAXCOL()/2 - 10 )
          if nChoice == 0
             ?? "Esc was pressed"
          else
             ?? "Selected option is", nChoice
          endif

Status

  Ready

Compliance

  This command is CA-Clipper compliant

Files

  Library is rtl

See Also

- @...PROMPT
- ACHOICE()
- SET MESSAGE
- SET INTENSITY
- SET WRAP
- __ATPROMPT()