Description
Terminates an internal or external subroutine, and returns control back to the main or calling program.
Syntax
Return [expression]
Parameters
The simple Return statement transfers control from an internal or external subroutine back to the statement in the main or calling program that immediately follows the GoSub or Call statement.
The Return expression form may only be used in functions and formulas in symbolic dictionary items. The result of expression is passed back to the calling program as a value that is used by the expression from which the call was made.
Execution of an End statement in an external subroutine has the same effect as a Return.
See also
Example
/* This function calculates age by comparing the external form of the birthday and today's date. The calculated age is passed back to the calling process in the Return statement. */ /* This is an example of both a return from a called subroutine and, also, a return from an internal subroutine. */ Compile Subroutine test_sub(CharStr parm) GoSub internal_sub: Return ;* this returns control to the calling program internal_sub: Return ;* returns to the statement following GoSub Compile Function TellAge(CharStr birthday) * returns age based on internal form of birthday Today = OConv(Date(), "D2-") Bday = OConv(birthday, "D2-") * calculate years Age = Today[7, 2] - Bday[7, 2] * has the birthday happened this year? If Today[1,5] LT Bday[1,5] Then Age -= 1 Return Age