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.

For Windows: Locally defined variables in external subroutines (and files opened to local file variables) are automatically abandoned or closed upon 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.

Example(s)

In this example, 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

See Also

call Statement, gosub Statement, on...gosub Statement, Statement Labels, subroutine Statement