Executes a Visual FoxPro program or procedure.


You can execute a program that executes another program that executes another program and so on by including additional nested DO commands in a program file. For more information about program nesting levels, see Visual FoxPro System Capacities.

DO ProgramName1 | ProcedureName [IN ProgramName2] [WITH ParameterList]



Specifies the name of the program to execute.

If you do not include an extension with the program you execute, Visual FoxPro looks for and executes versions of the program in the following order:

  • Executable (.exe)

  • Application (.app)

  • Compiled (.fxp)

  • Program (.prg)

To execute a specific menu program, form program, or query using the DO command, you must include the file extension (.mpr, .spr, or .qpr).


Specifies the name of the procedure to execute. Visual FoxPro first looks for the procedure in the currently executing program. If the procedure is not located there, Visual FoxPro then looks for the procedure in the procedure files opened with SETPROCEDURE.

You can include the IN ProgramName2 clause to tell Visual FoxPro to look for the procedure in a file you specify.

Multiple procedures within an executable (.exe) version or an application (.app) can have the same name. When you use the DO command to start a procedure in an executable version or in an application, Visual FoxPro searches only the main program of the executable version or application for the specified procedure.

IN ProgramName2

Executes a procedure in the program file specified with ProgramName2.

When the file is located, the procedure is executed. If the program file cannot be located, the message "File does not exist" appears. If the program file is located but the specified procedure isn't in the program file, the message "Procedure is not found" appears.

WITH ParameterList

Specifies parameters to pass to the program or procedure. The parameters listed in ParameterList can be expressions, memory variables, literals, fields, or user-defined functions. By default, parameters are passed to programs and procedures by reference. You can pass a parameter by value by placing it in parentheses.

See SET UDFPARMS Command for a discussion of passing parameters by value or reference. The maximum number of parameters you can pass to a program or procedure is 26. For more information on parameter passing, see LPARAMETERS Command and PARAMETERS Command.

Expand imageRemarks

Expand imageSee Also