| xHarbour Reference Documentation > Command Reference |
![]() |
![]() |
![]() |
Activates a text-mode menu defined with @...PROMPT commands.
MENU TO <xMenuVar>
MENU TO is a compatibility command activating a text-mode menu whose menu items are defined with @...PROMPT commands. When the menu is activated, the user can navigate a light bar with the cursor keys, indicating the currently selected menu item. The light bar is displayed in the enhanced color value of SetColor() while other menu items are displayed in the standard color.
A user selects a menu item by pressing the Return, PgUp or PgDn key. As a result, the MENU TO command terminates user input and assigns the ordinal position of the selected menu item as a numeric value to <xMenuVar>.
Menu selection is also terminated when the Escape key is pressed. In this case, no menu item is selected and the value zero is assigned to <xMenuVar>.
| See also: | @...PROMPT, AChoice(), SET MESSAGE, SET WRAP |
| Category: | Input commands |
| Source: | rtl\menuto.prg |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example builds a simple text-mode menu for editing
// a text file or browsing a database.
PROCEDURE Main
SET MESSAGE TO MaxRow()
SET WRAP ON
DO WHILE .T.
CLS
@ 3, 20 SAY "Select an option " COLOR "W+/R"
@ 5, 20 PROMPT "Database - Browse() " MESSAGE {|| MyMsg(1) }
@ 7, 20 PROMPT "Text file - MemoEdit()" MESSAGE {|| MyMsg(2) }
@ 9, 20 PROMPT "QUIT " MESSAGE {|| MyMsg(3) }
MENU TO nPrompt
SWITCH nPrompt
CASE 1
USE Customer
Browse()
USE
EXIT
CASE 2
MemoEdit( MemoRead( "TestMenu.prg" ) )
EXIT
DEFAULT
QUIT
END
ENDDO
RETURN
FUNCTION MyMsg( n )
SWITCH n
CASE 1 ; RETURN "Browses a database" ; EXIT
CASE 2 ; RETURN "Displays a text file" ; EXIT
CASE 3 ; RETURN "Ends program" ; EXIT
END
RETURN ""
http://www.xHarbour.com