<< Click to Display Table of Contents >> Gosub ... Return (statement) |
Gosub Label
.
.
.
Label:
Statement(s)
Return
Gosub jumps to a place in the script that is marked with the jump target Label; Return goes back to the calling place.
The jump target Label must reside inside the same subroutine or function from which the Gosub command is called.
Note: Gosub ... Return is provided only for compatibility with older Basic versions. It is recommended to use the statement Sub for subroutines instead.
See also: Goto, Sub, section Flow control
Example:
Sub Main
Print "Main program"
Gosub Detour
Exit Sub
Detour:
Print "Subroutine"
Return
End Sub