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 SYSFORMATS
, Set(“SysFormats”)This command yields the control of the date and time formats from the developer to the end user, a goal we find laudable.
SET SYSFORMATS ON | OFF
cOnOrOff = SET( "SYSFORMATS" )
We think it’s a good idea to let users choose the settings with which they are most comfortable. We should preserve their window positions, respect their color settings, and work with the screen resolution as configured. SET SYSFORMATS
has that attitude as well, yielding control of the date, currency, time and numeric formats to the Regional Options applet in the Windows Control Panel.
Help states that when SYSFORMATS is set on, you can use the following SET commands to override the Windows settings: SET CENTURY, SET CURRENCY, SET DATE , SET DECIMALS, SET HOURS, SET MARK TO, SET POINT, and SET SEPARATOR. Well, most work as you'd expect: After you SET SYSFORMATS ON, if you issue a SET command to override a setting, the data displays with the overridden format and the corresponding SET() function returns the overridden value (the one you just set it to). Not so with SET CENTURY and SET MARK. They properly pick up the Windows settings when SYSFORMAT is set ON. However, issuing a SET CENTURY or SET MARK does not override the formatting in SYSFORMATS, but the SYS() function returns a value that claims it does. |
But it’s very challenging to work in a system where you cannot determine the current settings. Generic date-parsing routines will have to be revised to more carefully manipulate the date setting, not to depend on switching and restoring SET DATE
. (Hint: If the setting of SYSFORMATS is ON and the DATE is SET to SHORT, you need to preserve and restore SET MARK TO
and/or turn on and off SYSFORMATS to parse the date.) Routines to automatically size a text box to fit the date cannot depend on SET(“CENTURY”). A routine that sets data session-scoped commands (as all of these are) to the default data session settings cannot always determine what these commands are set to. This command is a good idea; we’ll be pleased when tCENTURY and MARK are as functional as the rest.
SET SYSFORMATS ON
* In the Control Panel, set the short date to 'M/d/yy'
SET CENTURY ON
? SET("CENTURY") && "ON"
? DATE() && Yields a date in MM/DD/YY format.