Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

Do

This command runs a routine as a procedure (as opposed to a function).

Usage

DO ProcName [ WITH ParameterList ] [ IN FileName ]

Parameter

Value

Meaning

ProcName

Name

The procedure to execute.

ParameterList

List of expressions

The actual parameters to pass to the procedure.

FileName

Name

The name of a file containing the procedure.

Parameters to a procedure are passed by reference, except in three cases. The first is if the actual parameter is an expression rather than a variable or field. The second is if you put parentheses around the actual parameter (which, in effect, turns the item into an expression). Finally, properties are always passed by value rather than by reference. When variables are passed by reference, they must exist before the DO. See “Xbase Xplained” for more on parameter passing.

You can omit parameters in the call. Parameters at the end of the parameter list can be simply left off. Parameters in the middle can be omitted by placing nothing between the commas separating parameters. When a parameter is omitted, Visual FoxPro passes .F.

Using the IN clause can be pretty slow. See “Faster Than a Speeding Bullet” for speed comparisons of the different ways of calling a routine.

Example

DO MyRtn WITH a,b,c           && all passed by reference
DO MyRtn WITH 3*x,(b),DATE()  && all passed by value
DO MyRtn WITH a,,c            && omitted parameter

See Also

Procedure, Return