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.

Note: You do not need to specify the HLBPTR parameter when coding the HLL service routine invocation in the PL/I macro format. HLBPTR is inserted for you before the HLL service routine is started.

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*/
The descriptions for the steps shown in Using Pointer Variables in PL/I are:
 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');
Note: If you use the ADDR built-in function to represent a pointer to a varying length character string and the program is compiled with IBM® PL/I for MVS™ and VM V1R1M1, then the IEL0872I message might be generated by the compiler.