Sub name(param, param, Optional param, rest())
   commands
 EndSub

Define a subroutine. The subroutine can take parameters. The names of these parameters are specified in parentheses after the subroutine name.

If one parameter is preceded by Optional, all parameters following it are optional and can be omitted by the caller. They will report EMPTY when read.

The last parameter can be followed by (). This allows the caller to specify any number of values (including none at all) for this parameter, which will be packed into an array (making this a "varargs subroutine", for C programmers).

A subroutine can be called by listing its name, followed by the parameters:

 Sub test(a)
   Print a
 EndSub
 test "hello, world"

If there already is a subroutine or function with the same name as this subroutine, it will be replaced by the new definition.

Version Differences: PCC 1.x does not support the rest() form.

Since: PCC 1.0.6, PCC2 1.99.9

See also: Function

This is a testing version.
It may be incomplete, and have more bugs (or features) than the public live version at planetscentral.com.