return statement

The return statement terminates an internal or external subroutine, and returns execution control to the statement following the invoking call or gosub statement.

Syntax

return
return {to statement.label}

Parameter(s)

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.

Description

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.

Note: If the subroutine was executed from TCL, the return_value exits the subroutine and returns to TCL.

Example(s)

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:

function is compatible with other PICK vendors. You can also use sub. In this example, nCube is the return value.
fnCube 
001 function fnCube(px); 
002 nCube=px*px*px 
003 return nCube