The address built-in function (%ADDRESS or %ADDR) can be used to change or test the memory address stored in a CL pointer variable and can only be used within a CL procedure.
In a CHGVAR command, you can specify the %ADDRESS function to change the value of a pointer variable. On the IF command, %ADDRESS function can be specified on the COND parameter to check the value stored in a pointer variable.
%ADDRESS(variable name)or
%ADDR(variable name)
In the following example, pointer variable &P1 is initialized to the address of the first byte of character variable &C1. Later in the procedure, the pointer is checked using the %ADDRESS function to see if it still points to &C1 and, if not, resets &P1 to the first byte of CL variable &C1 using the %ADDRESS function.
PGM DCL &C1 *CHAR 10 DCL &P1 *PTR ADDRESS(&C1) : IF COND(&P1 *NE %ADDRESS(&C1)) + THEN(CHGVAR &P1 %ADDRESS(&C1)) : ENDPGM