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.


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


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


Print "Subroutine"

Print "..."

Return : ' to main program

EndOfProg: ' End




Main program