Condividi tramite


Creating Programs

A Visual FoxPro program is a text file containing a series of commands. You can create a program in Visual FoxPro in two ways:

To create a program

  1. In the Project Manager, select Programs under the Code tab.

  2. Choose New.

    -or-

  3. From the File menu, choose New.

  4. In the New dialog box, select Program.

  5. Choose New File.

    -or-

  • In the Command window, type:

    MODIFY COMMAND
    

Visual FoxPro opens a new window named Program1. You can now type your program into this window.

Saving Programs

After you create a program, be sure to save it.

To save a program

  • From the File menu, choose Save.

If you try to close an unsaved program, a dialog box opens, prompting you to either save or discard the changes you made to it.

If you save a program that was created from the Project Manager, the program is added to the project.

If you save a program that hasn't been named yet, the Save As dialog box opens so you can specify a name for the program. After you save your program, you can run or modify it.

Modifying Programs

After you save your program, you can modify it. First, open the program in one of these ways:

To open a program

  • If the program is contained in a project, select it in the Project Manager and choose Modify.

    -or-

  • From the File menu, choose Open. A dialog box with a list of available files appears. From the Files of type list, choose Program. From the list of files, select the program you want to modify, then choose Open.

    -or-

  • In the Command window, type the name of the program to modify:

    MODIFY COMMAND myprogrm
    

    -or-

  • In the Command window, type:

    MODIFY COMMAND ?
    

    From the list of files, select the program you want to modify, then choose Open.

After you open the program, you can make changes. When you finish making your changes, be sure to save the program.

Running Programs

After you create a program, you can run it.

To run a program

  • If the program is contained in a project, select it in the Project Manager and choose Run.

    -or-

  • From the Program menu, choose Do. From the list of programs, select the program to run, then choose Do.

    -or-

  • In the Command window, type DO and the name of the program to run:

    DO myprogram
    

See Also

Operating the Command Window | Creating Programs vs. Inputting Manually | Project Manager