ADDRESS OF Phrase in Expressions

In an arithmetic expression, you may use the address of a data item anywhere you can normally place a numeric data item. The address is treated as an unsigned integer with sufficient range to express any address in the host machine's address space.

To create an address, you use the following syntax:

ADDRESS OF data-item-1

where data-item-1 is a data item.

For example, the following statement produces a pointer that points one character position past the beginning of ITEM-1:

COMPUTE PTR-1 = ADDRESS OF ITEM-1 + 1

If a data item has not been given an address by the program, then the data item's address acts as if its uppermost parent item (or itself if it has no parent) has an address of zero. This makes it possible to test for a NULL address without generating a runtime exception. For example:

SET POINTER-1 TO ADDRESS OF LINK-ITEM-1
IF POINTER-1 = NULL
   SET ADDRESS OF LINK-ITEM-1 TO WS-ITEM-1

This rule only applies to ADDRESS OF calculations.