Partager via


RETURN Command

Returns program control to a calling program.

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

Parameters

  • eExpression
    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.

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

  • TO MASTER
    Returns control to the highest-level calling program.

  • TO ProcedureName
    Specifies the procedure to which control is returned.

Remarks

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.

Example 1

Description

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

Code

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

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

Example 2

Description

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.

Code

DEFINE CLASS t1 AS custom OLEPUBLIC
   DIMENSION Arrayelement[3]
   FUNCTION GetMyArray() AS array
      this.Arrayelement[1] = 1
      this.Arrayelement[2] = 2 
      this.Arrayelement[3] = 3
      RETURN @THIS.Arrayelement
   ENDFUNC
ENDDEFINE

See Also

Reference

DO Command

FUNCTION Command

LPARAMETERS Command

PARAMETERS Command

PARAMETERS( ) Function

PRIVATE Command

PROCEDURE Command

PUBLIC Command

Other Resources

Commands (Visual FoxPro)