Invoked a menu defined by set of @…PROMPT
__MenuTo( <bBlock>, <cVariable> ) --> nChoice
<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.
__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.
__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.
// 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
Library is core
@…PROMPT, AChoice(), SET MESSAGE, SET INTENSITY, SET WRAP, __AtPrompt()