Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Execution of an End statement in an external subroutine has the same effect as a Return.

See also

CallFunctionSubroutine

Example

Code Block
/* 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