Executes statements defined in the subroutine and returns control to the statement following the subroutine call.
SubName ( [ Arguments ] )
Zero or more Arguments separated by commas.
Nothing.
A subroutine is a procedure which has type Void, that is, it does not return a value.
For each procedure parameter which is not optional, there must be a corresponding argument expression. If no argument expression is supplied for an optional parameter, the default value specified for that parameter will be passed. An optional parameter can be explicitly omitted by just entering the comma which separates that argument from the next one. If all remaining parameters are optional they can all be omitted by entering the closing parenthesis which ends the argument list.
A Val parameter to a procedure is effectively a local variable of the procedure which is assigned the value of the corresponding argument expression before the procedure statements are executed. Any change to the value of the parameter only affects the local variable. No other variables in the calling procedure or global variables are affected. The argument expression will be converted to the data type of the parameter as necessary. It is an error if there is no such conversion.
A Var parameter is effectively a temporary alias to the corresponding argument. The argument expression passed to a Var parameter must a variable, array element, or structure field, and must have the same type as the parameter. Any change to the Var parameter is really a change to the passed argument.
After the parameters are initialized, control is transferred to the first statement of the procedure. The statements of the procedure are executed until a Return statement is encountered or the last statement of the procedure has been executed. At that time, control is transferred to the statement following the subroutine call.
The following examples demonstrate calls to subroutine procedures:
SetLogOff( )
Delay(1000)
The following examples demonstrate the omission of optional parameters. Assuming Subr has one required and two optional parameters, all of the following are valid subroutine calls:
Subr(a, b, c) ! explicitly supply values for all parameters
Subr(d) ! supply value for first parameter, use default for second and third.
Subr(e,,) ! same as above, but makes it obvious that parameters have been omitted
Subr(f,, g) ! supply value for first and third parameters, use default for second.