Caché MultiValue Basic Reference
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Class Reference   

Returns from a subroutine or function.
RETURN[(retval)] [TO label]
retval Optional (Functions Only) — An expression that evaluates to the return value for a user-defined function. The return value must be enclosed in parentheses. If not specified, an empty string is returned.
TO label Optional (Subroutines Only) — Any valid label. The label name can be optionally followed by a colon (:)
The RETURN statement is used to end execution of a user-defined subroutine or function and return control to the statement that invoked the subroutine or function.
The RETURN statement with no argument ceases execution of a subroutine and returns control to the GOSUB statement (for an internal subroutine) or the CALL statement (for an external subroutine) that invoked the subroutine. Program execution resumes with the line immediately following the GOSUB or CALL.
You can terminate an external subroutine with a RETURN or with an END statement.
The RETURN statement with a TO label clause ceases execution of a subroutine and transfers execution to the internal subroutine identified by the specified label.
The RETURN statement ceases execution of a function and returns retval to the location where the function was invoked. If no retval is specified, an empty string is returned.
Before invoking a user-defined external function, it is necessary to locally define the function using the DEFFUN statement.
See Also