Return

Return ends a script called by Gosub and resumes the execution to the instruction that follows the Gosub.

Syntax

  Return

Examples

# Call several labels by Gosub. These labels have a common return.
$ TEST_GOSUB
  Local Integer I
    Gosub INCREMENT
    Gosub INCREMENT_TWICE
    Gosub INCREMENT_THREE_TIMES
    # Here, the value of I is 6
Return
$INCREMENT_THREE_TIMES : I+=1
$INCREMENT_TWICE       : I+=1
$INCREMENT             : I+=1
Return

Description

Return returns the execution to the statement that follows the Gosub statement, as indicated by the following schema:

Execution order Instruction
1 Gosub MY_LABEL
2 $MY_LABEL
3 ... instructions following MY_LABEL
4 Return
5 ... instructions after Gosub
6 End

Comments

A script called by Call, fmet, or func cannot end by a Return but only by an End statement.

Associated errors

Execution order Instruction
32 Return encountered without preliminary Gosub.

See also

Gosub, Call, func, fmet, Subprog, Funprog.