Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
BAR()
, MENU()
, PAD()
, POPUP()
, PROMPT()
These functions tell you about your most recent menu choice. The first four indicate which bar, menu, pad or popup you picked. PROMPT()
returns the text for the chosen item. POPUP()
can also tell you if a particular popup has been defined.
nChosenBar = BAR()
cChosenMenu = MENU()
cChosenPad = PAD()
cChosenPopup = POPUP()
lPopupExists = POPUP( PopupName )
cChosenPrompt = PROMPT()
The timing for retrieving these items can be tricky. Your best bet is to pass them to the processing routine you set up with ON SELECTION, so you’re sure you get the right value.
These functions are set only when there are ON SELECTION commands for the items in question. For an item with no action set or with just an ON command, these functions don’t change.
For an interesting exercise in what changes when, add some pads with ON EXIT conditions at various levels to the system menu. Put the five functions here in the Debug window and make some choices. Watch when the various functions have values and when they’re empty. Putting WAIT WINDOWs in the ON EXIT conditions makes it particularly easy to see what’s going on. As FoxPro works its way down to the chosen item, the status functions reflect the level currently being processed.
ON SELECTION POPUP MyPop ;
DO ProcessPopup WITH POPUP(), BAR(), PROMPT()
Define Bar, Define Menu, Define Pad, Define Popup, Menus, On Exit Bar, On Exit Menu, On Exit Pad, On Exit Popup, On Selection Bar, On Selection Menu, On Selection Pad, On Selection Popup