Please enable JavaScript to view this site.

A-Shell Reference

GOSUB is used to call a "traditional BASIC subroutine". It is essentially equivalent to a GOTO (to the label at the start of the subroutine), with an internal stack marker used so that the next occurrence of a RETURN statement causes execution to proceed with the statement following the GOSUB. For example:

SECS = 4

GOSUB TARRY           ! same as CALL TARRY

PRINT "LET'S GO!"

...

 

TARRY:

SLEEP SECS

RETURN

 

Note that in "modern BASIC", structured procedures are generally preferable to GOSUB routines, since they allow parameter passing and local variables, eliminating the need for global variables such as the SECS variable in the example above.

Also note that the keyword CALL, while used to call Functions and Procedures, may be used in place of GOSUB to call traditional subroutines like the one above.