次の方法で共有


How to: Initialize the Environment

When Visual FoxPro starts, the default Visual FoxPro development environment establishes certain values for SET commands and system variables. However, these settings might not be the best environment for your application. Therefore, the first task that the main file or application object must perform is setting up the environment for the application.

Tip

It is recommended that you save the initial environment settings and modify them to set up a specific environment for your application. To see the default values of the Visual FoxPro development environment, start Visual FoxPro without a configuration file by typing VFP -C and then call the DISPLAY STATUS command. For more information, see DISPLAY STATUS Command.

To view and save settings for the current environment

  1. On the Tools menu, click Options.

  2. In the Options dialog box, press and hold the SHIFT key while you click OK.

    The SET commands and other environment settings display in the Command window.

  3. In the Command window, copy and paste the SET commands and environment settings into a setup program file.

You can now edit the SET commands and environment settings as appropriate for your application. In the environment for your application, you might want to include code to perform the following:

  • Initialize variables.

  • Establish a default path.

  • Open needed databases, free tables, and indexes. If your application requires access to remote data, the initialization routine can also prompt the user for the necessary login information.

  • Reference external library and procedure files.

For example, suppose you wanted to test the default value of the SET TALK command, store the value, and set TALK to OFF for your application. You might place the following code in your setup procedure:

IF SET('TALK') = "ON"
   SET TALK OFF
   cTalkVal = "ON"
ELSE
   cTalkVal = "OFF"
ENDIF

For more information, see SET Command Overview.

See Also

Tasks

How to: Set the Starting Point

How to: Control the Event Loop

Other Resources

Configuring an Application