Set, Set(), SYS(2001)
Probably the single most destructive command in the language, the SET command gives Visual FoxPro much of its power and much of its flakiness.
Usage |
SET SettingName ON | OFF SET SettingName TO uExpression |
ANSI |
DATABASE |
HOURS |
REFRESH |
cDateSet = SET("DATE") SET DATE ANSI sMyDate = CTOD(cYear+"."+cMonth+"."+cDay) SET DATE &cDateSetThe local setting method above does have its hazards. If any function or command can interrupt the execution of this snippet, you're back into the infinite-state machine—who knows what will happen? Two situations where we know this may happen are the execution of ON KEY LABEL functions and the automatic refreshing of a Grid/Browse. As usual, a little defensive programming can minimize the hazards. Within code called by ON KEY LABEL, use the same technique as above to save-change-restore any settings you need to work. Grids/Browses are a little trickier—the danger occurs if you change a setting that the grid depends upon for a display function, such as the SET DATE function above. The only work-around we know of is to use naming conventions in such a way that you'll know when it is unwise to make such changes. An alternative is not to use specific SET commands, such as SET DATE, within your routines if you plan to use grids—instead, use CASE statements to determine the current environment and use those settings to properly process your routine. Take a look at the examples included with the BITx() functions for some ideas on how to do this.
Usage |
uRetVal = SET( cSetting [, 1 | 2 | 3 ] ) uRetVal = SYS( 2001, cSetting [, 1 | 2 | 3 ] ) |
Example |
cDelSet = SET("DELETED") |
See Also |