Main Help → All Commands → Language Reference → Sub
The commands can include subroutines. All subroutines must be defined at the start of the commands. The commands that get executed and will call the subroutines must start with the first command after the last subroutine definition.
A subroutine, which can be called with a GoSub
command, is defined as follows:
Sub subname #arg1,#arg2,...,#argn (subroutine commands) . . . return
. . . EndSub
where
subname
is the name of the subroutine. The names of all subroutines must be unique.#arg1,#arg2,...,#argn
are any number of subroutine arguments. The name of each argument must be a valid variable name and must not be in quotes.EndSub
command and execution will return to the line after the GoSub
command that called the subroutine.return
command can be used to exit a subroutine at any time before the its end.GoSub
command for information on calling subroutines.GoSub
commands.