PROCEDURE
8.0.5
The PROCEDURE instruction defines a subroutine with parameters. It is the target of a parameterized CALL instruction. It also places the defined label in the public label table so that it may be accessed by other compiled subroutines. The instruction uses the following format:
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
list
Optional. A list of previously defined variables passed to and returned from the named procedure.
Flags Affected: NONE
Note the following:
The PROCEDURE instruction is only processed as the target of a parameterized CALL instruction. It is ignored if executed in-line.
The PROCEDURE instruction may be used in a loadable module and referenced in another compiled program by using the EXTERNAL definition.
The list of the parameterized CALL instruction is processed one item at a time. Type conversion is done if there is a type mismatch.
Any variable type or literal may be used in the list for the CALL instruction and may be real variables or pointer variables. The variables in the corresponding list for the PROCEDURE instruction must not be pointer variables. All argument passing is done by value. That is, the contents of each variable in the CALL list is moved to the corresponding variable in the PROCEDURE list.
All file variables found in the PROCEDURE list must be closed at the time of the CALL. If not, an F06 error occurs. The corresponding file variables in the CALL list are associated with the variables in the PROCEDURE list.
Common Data is not propagated to PROCEDURE modules and does not require data alignment. Any calling routine variables needed in a PROCEDURE module should be declared as GLOBAL or passed as arguments to module.
The corresponding RETURN instruction moves all variables back to the original variables.
Executing a NORETURN instead of a RETURN undefines all file variables in the PROCEDURE and all other variables are not moved back to the original variables.
If more variables are specified in the CALL list than in the PROCEDURE list, the extra variables are ignored. If more variables are specified in the PROCEDURE list than in the CALL list, the extra variables are zeroed or cleared exactly as if a CLEAR instruction had been performed on them.
The ROUTINE instruction handles parameter passing differently but otherwise is very similar to this instruction.
If a FILEPI instruction is active, the FILEPI count is not decremented by this instruction.
See Also: Example Code, CALL, ROUTINE, LROUTINE, RETURN, NORETURN, Program Control Instructions
![]() |