Command MENU TO Foundation

Activates light bar menu for previously defined PROMPTs.

Syntax
MENU TO <VarName>
Parameters
<VarName>
The result of the menu selection is assigned to the variable <VarName>. If the variable is not declared, it is created as a PRIVATE variable.
Description

The dialog command MENU TO provides menu navigation for the menu items previously defined using the command @...PROMPT. The first menu item selected when MENU TO is called can be set by assigning the appropriate numeric value to the variable <VarName>. If <VarName> is not declared or not initialized, the menu selection begins with the first menu item.

Menu items are displayed in the order they were declared using the command @...PROMPT. The menu item currently selected is displayed in the "highlighted" color (second color value) of the system color setting set with SetColor(). The other menu items are displayed in the default color (first color value).

The highlight (lighted bar) identifying the currently selected menu item is moved using the arrow keys. If a PROMPT was defined using the MESSAGE option and the display of messages is turned on with SET MESSAGE TO <nRow>, the message associated with the menu item is also displayed. If SET WRAP is turned ON, the highlight jumps from the last menu item to the first if the Down Arrow key is pressed while the highlight is on the last item. Conversely, the lighted bar skips from the first menu item to the last if the Up Arrow key is pressed while the highlight is on the first item. If a letter key is pressed, the highlight skips directly to the menu item whose first letter matches the key.

Menu selection is made by pressing the Return key. The numeric value corresponding to the position of the selected menu item is assigned to the variable<VarName>. The Esc key also terminates the menu selection but assigns the value zero to <VarName>.

The following table lists the keys processed by the command MENU TO and the actions they cause:

Keys for menu navigation with MENU TO
Key Default action
Up Arrow Previous menu item
Down Arrow Next menu item
Left Arrow Previous menu item
Right Arrow Next menu item
Home First menu item
End Last menu item
Page Up Terminates, returns position of current menu item
Page Down Terminates, returns position of current menu item
Return key Terminates, returns position of current menu item
Esc Terminates, returns 0
Beginning letter Terminates, returns position of next menu item, whose name begins with the letter

Navigation of the menu can also be done using the mouse. For this to work, SetMouse(.T.) must be called prior to the command MENU TO. When the mouse is active, a selection can be made by a click of the left mouse button on one of the menu items defined with @...PROMPT.

MENU TO commands can be nested if a key is assigned to a code block that calls a function or procedure which executes another MENU TO.

Examples
@...PROMPT and MENU TO
// The example shows a horizontal menu which outputs 
// three menu items on the top screen row and displays 
// messages centered on the bottom row. 

PROCEDURE Main 
   LOCAL nMenuItem := 1, PromptList:={} 

   CLS 
   SetColor( "N/BG,W+/B" ) 
   @ 0, 0                  // fill first row with blank spaces 

   SET WRAP ON 
   SET MESSAGE TO MaxRow() CENTER 

   @ 0, 1 PROMPT " DBF file " ; 
                  MESSAGE "Open and close DBF files" 

   @ Row(), Col()  PROMPT " NTX file " ; 
                  MESSAGE "Open and close index files" 

   @ Row(), Col()  PROMPT " Find " ; 
                  MESSAGE "Find records" 

   MENU TO nMenuItem 

   DO CASE 
   CASE nMenuItem == 0 
      ? "Terminated without selection" 
   CASE nMenuItem == 1 
      ? "Select DBF file" 
   CASE nMenuItem == 2 
      ? "Select index file" 
   CASE nMenuItem == 3 
      ? "Find record" 
   ENDCASE 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.