sub ... end sub
Subroutine definition.
Syntax:
sub
name
(
parmlist {...}
)
block
of instructions
end sub
name
is the subroutine name,
it's an alphanumeric string who must starts with a non numeric
character. For example: 1printString is incorrect while printString1 is
correct.
parmlist are one or more variables used to pass
argument to the subroutine.
While writing programs may happen you
need to repeat
the same sequence of instructions in several parts of the program.
sdlBasic offer you the chance of write the instruction sequence one
time and then recall it from every part of the program may needs it.
Variables used inside the subroutine are local variables, that means
they will not influence other variables that happens to use the same
variable name in your main program or in any other subroutine. This is
valid for arrays too. See Commons,
Shared and
Dim statements.
You can pass a list of parameters to
your
subroutine, but, unlike Function, you can't return any results.
Subroutine that do not require input parameters can be used in your
main program without brackets.
Example:
Sub
printString(a$)
prints(a$)
end
Sub
printString("yo!!!")
See also Commons,
Shared and
Dim commands.