LROUTINE


 

The LROUTINE instruction defines a subroutine with parameters. It is the target of a parameterized CALL instruction. The instruction uses the following format:

 

 

[label]

LROUTINE

[{parameters}]

 

Where:

label

Optional. A Program Execution Label.

parameters

Optional. A list of previously defined variables that are passed from the calling routine.

Flags Affected: NONE

Note the following:

  1. The LROUTINE instruction is only processed as the target of a parameterized CALL instruction. It is ignored if executed in-line.

  2. The {parameters} of the CALL instruction are processed one item at a time. Each corresponding list item in the LROUTINE instruction must be of the same type as the variable being processed from the CALL instruction. It is allowed to define a LROUTINE instruction with no list items. The variables in the list of a parameterized CALL instruction to this LROUTINE entry point are not initialized.

  3. Any variable type may be used in the list for the CALL instruction. The variables in the corresponding list for the LROUTINE instruction should be defined as pointer variables. If defined in this manner, all argument passing is done by variable addresses and any variable modified in the LROUTINE subroutine modifies the original variable.

  4. 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.

  5. If any DIMs, FORMs, or INTEGERs in the LROUTINE list are defined as simple variables (not pointer variables), the passing of information to the LROUTINE 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 LROUTINE instruction. The variables are not moved back to the calling program for these cases.

  6. An LROUTINE 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.

  7. A typeless parameter may be defined by using a variable of type VAR.

  8. If more variables are specified in the CALL list than in the LROUTINE list, the extra variables are ignored. If more variables are specified in the LROUTINE list than in the CALL list, the extra variables are left as previously defined. Care should be taken in this instance to make sure that at least one CALL has been performed that initializes all variables in the LROUTINE 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.

  9. If a FILEPI instruction is active, the FILEPI count is not decremented by this instruction.

 

 

See Also: Example Code, CALL, EXTERNAL, LOADMOD, PROCEDURE, ROUTINE, XCALL, Program Control Instructions

 



PL/B Language Reference LOOP,UNTIL,WHILE,REPEAT NOBREAK