xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

MENU TO

Activates a text-mode menu defined with @...PROMPT commands.

Syntax

MENU TO <xMenuVar>

Arguments

<xMenuVar>
This is the name of a memory variable to receive the result of menu selection. If the variable does not exist, a PRIVATE variable of this name is created.

Description

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>.

Info

See also:@...PROMPT, AChoice(), SET MESSAGE, SET WRAP
Category: Input commands
Source:rtl\menuto.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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 ""

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe