Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
RETURN Command
Collapse the table of content
Expand the table of content

RETURN Command

Returns program control to a calling program.

RETURN [eExpression | oObjectName | TO MASTER | TO ProcedureName]



Specifies an expression returned to the calling program. If you omit RETURN or the return expression, true (.T.), it is automatically returned to the calling program.


Specifies the object to which focus is assigned. Applies only to Valid Event.


Returns control to the highest-level calling program.

TO ProcedureName

Specifies the procedure to which control is returned.

RETURN terminates execution of a program, procedure, or function and returns control to the calling program, the highest-level calling program, another program, or the Command window.

Visual FoxPro releases PRIVATE variables when RETURN is executed.

RETURN is usually placed at the end of a program, procedure, or function to return control to a higher-level program. However, an implicit RETURN is executed if you omit RETURN.

You can direct where focus is assigned using the optional oObjectName parameter in the RETURN command of the Valid Event. The object specified must be a valid Visual FoxPro object. If the specified object is disabled or cannot receive focus, then focus is assigned to the next object in the tab order. If an invalid object is specified, Visual FoxPro keeps the focus at the current object. You can now set focus to objects on another visible form or on a non-visible Page or Pageframe control.

In the following example, the function longdate returns a character string that is suitable for printing from a date.

? longdate({^1998-02-16})  && Displays Monday, February 16, 1998

FUNCTION longdate
RETURN CDOW(mdate) + ', ' + MDY(mdate)

You can return arrays directly from a class method using the @ operator. Returning arrays from a class method allows Visual FoxPro COM components to communicate with other COM components such as those written in Visual Basic or Visual C++. This can affect methods implemented from an interface using the IMPLEMENTS clause.

Because such arrays must be in scope after the method call, LOCAL and PRIVATE arrays are invalid in these declarations. You must use either a PUBLIC or a member array. This array support does not work with the STORE TO command.

In the following example, the class t1 has a function GetMyArray returns an array.

   DIMENSION Arrayelement[3]
   FUNCTION GetMyArray() AS array
      this.Arrayelement[1] = 1
      this.Arrayelement[2] = 2 
      this.Arrayelement[3] = 3
      RETURN @THIS.Arrayelement

Community Additions

© 2015 Microsoft