JavaScript Editor js editor     Web development 

Main Page

You can establish configuration settings when you first start the program, which allows you to override default settings.

Using SET Commands in Applications

One way to establish configuration settings is to issue one or more SET commands when your application starts. For example, to configure your system to display a clock in the status bar when the application starts, you can issue this SET command:

В Copy Code

The exact point at which you issue the SET command depends on your application. In general, you issue SET commands from your application's main program file, which is the program or form that controls access to the rest of your application. You can also issue SET commands from the Load or Init events of the form. If you are using private data sessions, it may be necessary to make these settings in the BeforeOpenTables Event of your DataEnvironment object. For details about specifying a main file for an application, see Compiling an Application.

If your application has a form set as main in the project manager, and it then launches a menu, you can add SETUP commands by entering them in the menu's Setup option. For details see How to: Add Setup Code to a Menu System in Designing Menus and Toolbars.

An efficient way to manage SET commands for startup is to create a procedure that contains all the commands that you want to issue. You can then call the procedure from the appropriate point in your application. Keeping all the SETUP commands in a single procedure makes it easier to debug and maintain your configuration settings. You can also put the code in the class on which your application object is based, or the class on which your forms are based.

Using a Configuration File

In addition to setting the Visual FoxPro environment using the Options dialog box or SET commands, you can establish preferred settings and save them in one or more configuration files. A Visual FoxPro configuration file is a text file in which you can specify values for SET commands, set system variables, and execute commands or call functions. Visual FoxPro reads the configuration file when starting up, establishing the settings and executing the commands in the file. Settings made in the configuration file override default settings made in the Options dialog box (and stored in the Windows registry).

Using a configuration file provides several advantages. You can:

  • Override the default settings established in the Options dialog box.

  • Maintain several different configuration files, each with different settings, so that Visual FoxPro can load a configuration suitable to a particular user or project.

  • Make changes more easily than if you establish settings with the SET commands in the program initialization sequence.

  • Start a program or call a function automatically when Visual FoxPro starts.

For instructions about working with configuration files, see How to: Create a Configuration File and How to: Specify the Configuration File.

See Also

JavaScript Editor js editor     Web development