Configuration Files

There are a number of configuration files that you can take advantage of to customize Visual FoxPro, either in your development environment or in your users' runtime environments, but sometimes not both. Here we'll review some of the rules and hazards involved in that.

Registry

The Windows registration database is Microsoft's solution to the complaints that thousands of INI files crowd the Windows subdirectory. INI files, as we discuss below, are text files, easily edited by any end user with Notepad. To minimize multiple files, add a little bit of security, and also to allow remote maintenance of these settings, Microsoft has placed everything in the Registry. Unfortunately, we don't think Microsoft went far enough.

The developer environment stores dozens of settings in the Registry, but runtime environments do not, by default, read these same settings. This puts the developer in the situation where she may develop and test an app in an artificial environment that may be different from the user's environment. See "Registration Database" for more details.


Options dialog

The tabbed dialog available under the Tools | Options menu has a slew of settings for the developer. This is an easy, and safe, window into the Registry. The Installation Guide that comes with Visual FoxPro, under "Configuring Visual FoxPro," goes into these settings in great depth, so we won't repeat the list here.

Hold down the SHIFT key while clicking the OK button within the Options dialog and all the settings that have corresponding SET commands are echoed to the command window!


Config.FPW

Config.FPW stores a number of SET commands, as well as some special options available only in this file. How Visual FoxPro determines which Config.FPW file to use is a bit tricky. In the development environment, Visual FoxPro first checks to see if Visual FoxPro has been started up with the command line –C startup switch. If you've modified the shortcut's properties, or created a command line, such as:
D:\VFP\VFP.EXE -CD:\PROJECTS\CONFIG.VFP
Visual FoxPro uses the specified file. Next, Visual FoxPro checks for a DOS environment variable FOXPROWCFG. If this exists, the file it points to is used. If not, Visual FoxPro searches the current directory, and then the DOS path for a file named Config.FPW. VFP uses the DOS path only, because the FoxPro path has not yet been established.The runtime environment operates a little differently. For an APP or an EXE, besides using the methods above, you may include a file named Config.FPW in the project, using the Other-Text Files section. Visual FoxPro uses this file before starting the same sequence as the development environment.SYS(2019) returns the path and filename of the current configuration file.

FoxPro.INI

In FoxPro for Windows and Visual FoxPro 3.0, FoxPro.INI stored the desktop settings to use on startup: the position and zoomed status, as well as the default desktop and printer font name, size and style. The file is in the main Windows directory. Visual FoxPro 3 settings are stored in a section cleverly named FoxPro 3. Typical settings look like the following:
[FoxPro 3]
Zoomed=1
Row=-4
Column=-4
Height=580
Width=808
FontName=Courier New
FontStyle=1
FontSize=9
PrtFontName=FoxPrint
PrtFontStyle=0
PrtFontSize=10
See the entry on "INI files" for information on manipulating these entries programmatically.In Visual FoxPro 5.0 and later, these settings are stored on an individual user basis in the Registry under the key HKEY_CURRENT_USER\Software\Microsoft\VisualFoxPro\ {version} \Desktop, where {version} is 5.0, 6.0, and so forth.In an application, you will probably want to start with SCREEN=OFF in your Config.FPW file, then set the settings of initial position and fonts based either on your application's requirements or on settings you have preserved from the last run of the program.

FOXUSER.DBF—The Resource File

Within FOXUSER, settings are stored for even more stuff. Earlier versions of FoxPro stored many other pieces of information, such as printer settings, which used to bloat this file. Now its primary purpose is to store the position and size of windows, toolbars and design surfaces you've worked with, restoring them to their previous positions when they are called up again. If you misplace a toolbar, somehow managing to position it off-screen, perhaps by changing your screen resolution, delete the associated record in the resource file to bring it back to its default. SYS(2005) returns the current file used as a resource file; SET RESOURCE turns it on or off or points it to a different file.In VFP 6 and earlier, this resource file must be used exclusively. The first instance of VFP to open got the resource file, leaving the remaining instances with no resource file at all. Starting with VFP 7, the resource file is shared, so you can now open instances of VFP and they'll all use the same resource file. Likewise, multiple users can access the same resource file.

Command Line Switches

We often hear of people running into problems that sound like something confused in the Registry. Use the –A command line switch to start FoxPro without reading the current Config.FPW and Registry switches. Use –R to re-establish the associations that Visual FoxPro has with file extensions in Explorer and File Manager. Starting in VFP 7, two more command line switches were added to make VFP more like other Microsoft products that support command line switches. The /? switch lists the command line switches, and the –Bpicturename switch displays the specified graphics file (.GIF, .JPG, or .BMP) as a splash screen while VFP loads.

See Also

INI Files, Registration Database, Set, Set Resource, Sys(2005), Sys(2019)


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .