Locator variables
Because a locator variable identifies the location of any generation, you can refer at any point in a program to any generation of a based variable by using an appropriate locator value.
The following example declares that references to
X,
except when the reference is explicitly qualified, use the locator
variable P to locate the storage for X.
dcl X fixed bin based(P);The association of a locator reference in this way is not permanent.
The locator reference can be used to identify locations of other based
variables and other locator references can be used to identify other
generations of the variable X. When a based variable
is declared without a locator reference, any reference to the based
variable must always be explicitly locator-qualified.
In the following example, the arrays
A and C refer
to the same storage. The elements B and C(2,1) also
refer to the same storage. dcl A(3,2) character(5) based(P),
B char(5) based(Q),
C(3,2) character(5);
P = addr(C);
Q = addr(A(2,1));Note: When a based variable is overlaid in this way, no new storage
is allocated. The based variable uses the same storage as the variable
on which it is overlaid (
C(3,2) in the example).