Pointer variables
A pointer variable is a 4-byte pointer field containing an address. All HLL service routines require at least one argument called HLBPTR. The NetView® program calculates the value of HLBPTR and passes it to a PL/I HLL command processor or installation exit. Therefore, HLBPTR must be declared only in PL/I. Do not assign a value to the HLBPTR variable. This is the only parameter of this type that you do not have to assign.
If an HLL service routine expects an address in a pointer field, you are responsible for assigning a value to that pointer field before starting the HLL service routine. In PL/I, you can use the ADDR function when passing pointer variables to HLL service routines rather than creating a separate pointer variable for this purpose. This ensures that the pointer variable has been assigned a value before starting the HLL service routine.
Using Pointer Variables in PL/I shows how to use pointer variables in PL/I. More information for the numbered steps follows the figure.
Using Pointer Variables in PL/I
DCL VARTOVAR CHAR(8) INIT('VARTOVAR'); /* VARTOVAR constant */
1 DCL HLBPTR PTR; /* HLB pointer MUST BE DECLARED! */
2 DCL SRCPTR PTR; /* Source pointer */
DCL DSTPTR PTR; /* Destination pointer */
DCL DSTLEN FIXED BINARY(31,0); /* Length of Destination */
DCL SRCBUF CHAR(255) VARYING; /* Source buffer */
DCL DSTBUF CHAR(255) VARYING; /* Destination buffer */
3 SRCPTR = ADDR(SRCBUF); /* Address of source buffer */
DSTPTR = ADDR(DSTBUF); /* Address of destination buffer */
DSTLEN = LENGTH(DSTBUF); /* Length of destination buffer */
SRCBUF = (255)'A'; /* Initialize source buffer */
DSTBUF = (255)' '; /* Initialize destination buffer */
4 CALL CNMCPYS(HLBPTR,SRCPTR,DSTPTR,DSTLEN,VARTOVAR); /* Copy buffer*/- 1
- HLBPTR is declared as a pointer (PTR) variable to be used in the CNMCPYS invocation. You must not assign a value to HLBPTR. HLBPTR is specified for this invocation because you started CNMCPYS using the PL/I call format, rather than the PL/I macro format. Service reference contains examples of how to start HLL service routines using the PL/I macro format.
- 2
- SRCPTR is declared as a pointer (PTR) variable.
- 3
- SRCPTR is assigned the address of the source buffer (SRCBUF) to be used in the CNMCPYS invocation.
- 4
- Both HLBPTR and SRCPTR have been passed as parameters to CNMCPYS. Using the ADDR
function eliminates the need to declare pointer (PTR) variables. Note
here the use of a character constant instead of the VARTOVAR variable:
CALL CNMCPYS(HLBPTR,ADDR(SRCBUF),ADDR(DSTBUF),DSTLEN,'VARTOVAR');