Share via


Adding Files to a Project

A Visual FoxPro project consists of separate components that are stored as individual files. For example, a simple project might consist of forms (.scx files), reports (.frx files), and programs (.prg and .fxp files). In addition, a project usually has one or more databases (.dbc files), tables (stored in .dbf and .fpt files) and indexes (.cdx and .idx files). To be included in an application, a file has to be added to your project. That way, when you compile your application, Visual FoxPro can include the files for that component in the finished product.

You can easily add files to a project in a number of ways:

  • To create a project and add existing files, use the Application Wizard.
  • To automatically add new files to a project, open a project, then create the new files from within the Project Manager.
  • To add existing files to a project, open a project and add them using the Project Manager.

If you've used the Application Wizard or Project Manager to create the files, you usually don't need to do anything else — the file is automatically included in the project. One exception, however, is if your application includes a file that will be modified by the user. Because included files are read-only, you must mark the file as excluded. For more information, see Referencing Modifiable Files.

Tip   For a list of file types and extensions used in Visual FoxPro, see File Extensions and File Types.

Creating and Modifying Files with Project Manager

The Project Manager simplifies creating and modifying files. Just select the type of file you want to create or modify and choose the New or Modify button. Visual FoxPro displays the design tool appropriate to the type of file you selected.

To create a file to add to the Project Manager

  1. Select the element you want to create.
  2. Choose New.

With some items, you have the option to use a wizard to help you create the file.

To modify a file

  1. Select an existing file.
  2. Choose Modify.

For example, to modify a table, select the name of the table and choose Modify to display the table in the Table Designer.

Adding a Description to a File

When you create or add a new file, you can add a description to the file. This description is shown at the bottom of the Project Manager when the file is selected.

To add a description to a file

  1. In the Project Manager, select the file.
  2. From the Project menu, choose Edit Description.
  3. In the Description dialog box, type a description for the file.
  4. Choose OK.

Adding an Existing File to a Project

If an existing file is not already part of your project, you can add it manually.

To add a file to a project manually

  1. In the Project Manager Window, choose the type of component you want to add by selecting it in the hierarchy.
  2. Choose Add.
  3. In the Open dialog box, select the file you want to add.
  4. Choose OK.

To remove a file from a project

  1. Select the element you want to remove.
  2. Choose Remove.
  3. In the confirmation prompt, choose Remove.

If you want to delete the file from your computer, choose Delete.

Visual FoxPro also adds files to your project if you reference them in a program or form. For example, if a program in your project includes the following line, Visual FoxPro adds the file Orders.scx to your project:

DO FORM ORDERS.SCX

If a file is referenced in this way, it is not immediately included in a project. Later, when you build the project, Visual FoxPro resolves references to all files and automatically includes implicit files in the project. Additionally, if any other file is referenced through user-defined code within the new file, building the project will also resolve that reference and include the file. The referenced files appear in the Project Manager the next time you view the project.

Caution   Visual FoxPro might not be able to resolve references to picture (.bmp and .msk) files, depending on how they are used in code. Therefore, add pictures to your files manually. In addition, Visual FoxPro cannot automatically include files that are referenced using macro substitution, because the name of the file is not known until the application is running. If your application references files using macro substitution, include the referenced files manually.

See Also

Structuring a Program as a Main File | Referencing Modifiable Files | Compiling an Application | Application Wizard