ROUTINE
7.8.6, PLBCMP Only
The ROUTINE 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 used by other compiled subroutines. The instruction uses the following format:
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
parameters
Optional. A list of previously defined variables passed from the CALLing routine.
Flags Affected: NONE
Note the following:
The ROUTINE instruction is only processed as the target of a parameterized CALL instruction. It is ignored if executed in-line.
The {parameters} of the CALL instruction are processed one item at a time. Each corresponding list item in the ROUTINE instruction must be of the same type as the variable being processed from the CALL instruction.
Any variable type may used in the list for the CALL instruction. The variables in the corresponding list for the ROUTINE instruction can be defined as pointer variables. If defined in this manner, all argument passing is done by variable addresses and any variable modified in the ROUTINE subroutine modifies the original variable.
A literal may be used in the list for the CALL instruction if the corresponding variable in the LROUTINE (or ROUTINE) is defined as a DIM, FORM, INTEGER, DIM pointer or VAR pointer.
If any DIMs, FORMs, or INTEGERs in the ROUTINE list are defined as simple variables (not pointer variables), the passing of information to the ROUTINE is by value. That is, an internal MOVE instruction is performed to move the contents of the variable specified on the CALL instruction to the contents of the variable specified on the ROUTINE instruction. The variables are not moved back to the calling program for these cases.
A ROUTINE with a DIM or VAR pointer parameter references a duplicate image of the input literal. The duplicate image of the literal can be manipulated like any DIM variable without affecting or corrupting the original literal data. For this specific usage, the CALL USING literal has a maximum size limit of 2047.
A routine expecting a pointer to a RECORD as a parameter must pass in a pointer to a RECORD. Attempting to call the routine using a RECORD variable will result in an F05 runtime error. In addition, the ROUTINE will not have any knowledge of the structure of the incoming RECORD.
A typeless parameter may be defined by using a variable of type VAR.
If more variables are specified in the CALL list than in the ROUTINE list, the extra variables are ignored. If more variables are specified in the ROUTINE list than in the CALL list, the extra variables are left as previously defined. Care should be taken to make sure that at least one CALL has been performed that initializes all variables in the ROUTINE list or the variables have been previously initialized with a MOVEADDR or MOVEPTR instruction. It is possible to have a parameterized call with no items in the list.
Common Data is not propagated to ROUTINE modules and does not require data alignment. Any calling routine variables needed in a ROUTINE module should be declared as GLOBAL or passed as arguments to the module.
If a FILEPI instruction is active, the FILEPI count is not decremented by this instruction.
See Also: Example Code, CALL, EXTERNAL, LOADMOD, LROUTINE, PROCEDURE, XCALL, Program Control Instructions
![]() |