SUB <subroutine name>(<parameters>)
<codes>
.......
ENDSUB
SUB <subroutine name> is a statement within a script file. It specifies the beginning of each subroutine in a script file and defines the subroutine name and parameters. Subroutine names must begin with a letter or underscore and may contain any combination of letters, numbers and underscores.
The SUB <subroutine name> command line is followed by a series of commands that make up the subroutine. You must include ENDSUB as the last line of a subroutine.
The difference between FUNC and SUB is that FUNC can return a value, but, SUB cannot.
To use a subroutine, simply include the subroutine name followed by its parameters into your codes (see example). Advance users may want to pass a parameter by reference. To pass a parameter by reference, prefix the parameter name with &.
Example:
SUB GetName(prompt, &name)
'-- name will be modified
INPUT prompt, name
ENDSUB
See Also