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 FORMAT
, Set(“Format”), Sys(7)These commands control the use of format files. SET FORMAT
lets you specify a format file, while SET(“FORMAT”) and SYS(7) tell you the name of the current format file.
SET FORMAT TO [ cFileName | ? ]
cFormatFile = SET( "FORMAT" )
cFormatFile = SYS( 7 [, nWorkArea ] )
Way back in Xbase history, someone had the bright idea of letting users specify formatting and validation information about fields once, then be able to use that information with the built-in input commands. The result was the format file, a collection of SAYs and GETs, with no READ in sight. You SET FORMAT
TO such a file (which normally has a .FMT extension), then issue EDIT, APPEND or INSERT. Instead of the default appearance, those commands use the SAYs and GETs to present a formatted screen. It was actually quite a good idea … at the time.
Once the Screen Builder appeared in FoxPro 2, format files were rendered obsolete. Visual FoxPro drove another nail into the coffin with its OOP Form Designer.
SET FORMAT
TO some filename specifies the format file to use. SET FORMAT
TO with no file turns it off.
Don’t bother. Use the Form Designer.
For every action, there’s an equal and opposite reaction. If we can specify a format file, there must be a way to find out what it is. This being FoxPro, there are two ways. SET(“FORMAT”) and SYS(7) are nearly identical. Like so many of the SET()
functions, SET(“FORMAT”) is undocumented. Both return the fully qualified path and file name for the format file in the current work area. SYS(7) can look at other work areas as well, if you add the second parameter.