Gosub ... Return

Gosub LINE

Gosub transfers control to the line specified. The position is saved so that execution will continue on the next line when a return is encountered. The gosub recursion depth is only limited by memory.

The Gosub command can only be used to transfer control to a line label type subroutine. It can not be used to call the new Sub type subroutines.

Print "Main Program"
GoSub SubPrint

Print "Back To Main"

GoSub SubPrint
Print "Once again Main"


Print "This is the Subroutine"

This type of subroutine is provided for compatibility with older Basic programs. All new programs should use the new Subroutine/Function syntax.


Become a Patron