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.
SET SKIP
Of, SKPBAR()
, SKPPAD()
Here’s another command that’s easy to confuse. SET SKIP
OF is about menus. SET SKIP
TO is about relations. We’re interested in menus right now.
SET SKIP
OF lets you turn individual menu components on and off. When a component is turned off, its prompt dims and the user can’t choose it—sort of. SKPBAR()
and SKPPAD()
tell you the status of individual bars and pads.
SET SKIP OF MENU MenuName lSkipIt
SET SKIP OF PAD PadName OF MenuName lSkipIt
SET SKIP OF POPUP PopupName lSkipIt
SET SKIP OF BAR nBar OF PopupName lSkipIt
These commands work inside out—when you SET SKIP
of some component to .T., it gets disabled. In fact, it works the same way as the SKIP FOR clause of the various DEFINE commands for menu components. Like SET DELETED
, it’s just one of those things that’s backward. Consider it sort of a Disabled property—then the double negatives make some sense!
Like so many other menu commands, the MENU and POPUP versions of this one propagate downward. SET SKIP
OF a popup to .T. and every bar on the popup is disabled. You can then enable individual bars with SET SKIP
OF BAR.
Unlike SKIP FOR, SET SKIP
OF is not dynamically evaluated. That is, lSkipIt is evaluated when you issue the command and the item’s status is set accordingly. But changes to lSkipIt after that do not affect that menu item. Use SKIP FOR to set up conditions that are evaluated repeatedly. (You can refresh the menu and update the SKIP status by issuing ACTIVATE MENU
MenuName NOWAIT.)
In the system menu, disabling a pad prevents you from opening that pad, so you can't get to the items on the pad's associated popup. In non-system menus, that's not the case. To disable all the items below a pad, you have to SET SKIP OF the pad and of the popup associated with it. |
* Turn off the view menu
SET SKIP OF PAD _MSM_View OF _MSysMenu .T.
lIsSkipped = SKPBAR( cPopupName, nBar )
lIsSkipped = SKPPAD( cMenuName, cPadName )
When you need to know if a menu item is available at the moment, these two are the ticket. The results are changed by the SET SKIP
OF commands and the SKIP FOR clause of the various DEFINE commands.
As with MRKBAR()
, to check SKPBAR()
for bars of the system menu, you need to specify the bar name, which is really a negative number. (Being able to check the system menu bars lets you set up buttons that are enabled and disabled based on the corresponding menu item. You’re most likely to use this with a toolbar so you can, for example, have Cut, Copy and Paste buttons that are enabled only when they’re relevant.)
? SKPPAD("_MsysMenu", "_MSM_View") && Returns .T. after above
? SKPBAR("_Medit",_Med_Undo) && Test whether Undo is disabled