POINTERADD
POINTERADD returns a pointer value that is the sum of its arguments.
Abbreviation: PTRADD
- x
- Pointer expression.
- y
- Expression that must have a computational type and is converted to FIXED BINARY(31,0).
POINTERADD can be used as a locator for a based variable.
POINTERADD can be used for subtraction by prefixing the operand to be subtracted with a minus sign.
There is no need to use POINTERADD to increment a pointer - you
can simply increment the pointer as you would an integer. For example,
there is no need to write:
p = pointeradd(p,2);
Instead, you could write either of the following equivalent statements:
p = p + 2;
p += 2;
However, POINTERADD can be useful in dereferencing the storage
at a location offset from a pointer, as in the following example:
dcl x fixed bin(31), b based fixed bin(31);
x = pointeradd(p,2)->b;
Note, however, since a locator in PL/I must be a reference, you
cannot write
x = (p + 2)->b;