GETBAR( ) Function
Returns the number of an item on a menu defined with DEFINE POPUP or the Visual FoxPro system menu.
GETBAR(MenuItemName, nMenuPosition)
Return Value
Numeric
Parameters
MenuItemName
Specifies the menu item.nMenuPosition
Specifies a position on the menu. nMenuPosition can range from 1 through the number of items within the menu. 1 corresponds to the first item on the menu, 2 to the second item, and so on.
Remarks
Use GETBAR( ) to determine which item occupies a specific position on a menu. This function is useful when items on a menu are added, removed, or rearranged. Use DEFINE BAR to add an item to a menu or RELEASE BAR to remove an item. The position of items in a menu can be changed if MOVER is included when the menu is created with DEFINE POPUP.
Example
The following example creates a menu named popDemo. The MOVER keyword is included so the items in the menu can be rearranged. For information about rearranging menu items, see the MOVER clause in DEFINE POPUP.
The menu is activated, and a series of GETBAR( ) functions are used in PRMBAR( ) to return captions of each item. After you rearrange the items, press CTRL+Z to display the new item order.
CLEAR
ON KEY LABEL CTRL+Z DO showorder
WAIT WINDOW "Press CTRL+Z to refresh." NOWAIT
DEFINE POPUP popDemo MOVER FROM 2,2
DEFINE BAR 1 OF popDemo PROMPT 'One'
DEFINE BAR 2 OF popDemo PROMPT 'Two'
DEFINE BAR 3 OF popDemo PROMPT 'Three'
DEFINE BAR 4 OF popDemo PROMPT 'Four'
DO showorder
ACTIVATE POPUP popDemo
PROCEDURE showorder
CLEAR
@ 3,12 SAY '1 ' + PRMBAR('popDemo', GETBAR('popDemo',1))
@ 4,12 SAY '2 ' + PRMBAR('popDemo', GETBAR('popDemo',2))
@ 5,12 SAY '3 ' + PRMBAR('popDemo', GETBAR('popDemo',3))
@ 6,12 SAY '4 ' + PRMBAR('popDemo', GETBAR('popDemo',4))
RETURN