The return statement terminates an internal or external subroutine, and returns execution control to the statement following the invoking call or gosub statement.
return return {to statement.label}
statement.label | Specifies the statement to which control is returned. |
return_value |
The return_value terminates an internal or external function, and returns execution control to the statement following the invoking call or gosub statement. Required if returning from a user-defined function (deffun statement) as opposed to a local sub-routine call or remote sub-routine call. |
For Windows: Locally defined variables in external subroutines (and files opened to local file variables) are automatically abandoned or closed on return.
The to clause can only be used with an internal subroutine, and transfers control to the specified statement label. This is not a recommended programming practice.
Example 1:
If the answer is y, then call internal subroutine 1000. When 1000 is complete, control is returned to the line that prints back again.
input answer if answer = ’y’ then gosub 1000 print ’back again’ stop 1000 * subroutine print ’ok’ return
Example 2:
fnCube 001 function fnCube(px); 002 nCube=px*px*px 003 return nCube