Statement RETURN Foundation

Ends procedure, user-defined function or program.

RETURN [<Expression>]
The RETURN statement ends a procedure or a user-defined function and control passes to the calling function or procedure. <Expression>is returned as a function value. Procedures have no return value, meaning they return the value NIL. If <Expression> is not supplied, functions return NIL. Functions with no return value produce a compiler warning.

A user-defined function (UDF), a procedure or a program is ended with RETURN and control passes back to the calling function or procedure. When RETURN is used in the Main function or procedure, control returns to the operating system. All LOCAL and PRIVATE variables declared in the RETURNing function or procedure are released. In the case of an UDF, the value of <Expression> is returned to the calling routine. <Expression> can be of any data type.

A procedure or UDF ends when a new FUNCTION, PROCEDURE, CLASS or METHOD declaration or the end of file are encountered. It is good programming practice to indicate the end of a procedure or UDF with the RETURN declaration. Multiple RETURN statements can be in a UDF or procedure, but a good programming practice is to place a single RETURN at the end of the UDF or procedure. BEGIN SEQUENCE..ENDSEQUENCE can be used to break out of code sections and get to the ending RETURN statement.

If RETURN is executed in the Main() function, and <Expression> is a numeric value, this value is passed to the function ErrorLevel() before the program finally terminates.

RETURN usage
// Almost all of the examples of Xbase++ documentation contain 
// a compilable program example in which the RETURN 
// statementdeclaration is used (see another example). 

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.