GoSub - Return

GoSub <label> | <line number>

Branches unconditionally out of the normal program sequence to a specified subroutine at labeled or numbered line, but upon encountering the Return statement, it jumps back to the line following the line from which the jump occurred. This can be used to implement subroutines.

See also Function - End Function and Sub - End Sub.

Return

Returns from subroutine, branching back to the line following the most recent GoSub statement line

Example:

10 GoSub 40

20 Print "Main program"

30 GoTo 70

40 Print "Subroutine"

50 Print "..."

60 Return : ' to main program

70 ' End

GoSub Subroutine

Print "Main program"

GoTo EndOfProg

Subroutine:

Print "Subroutine"

Print "..."

Return : ' to main program

EndOfProg: ' End

Output:

Subroutine

...

Main program