Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Language Reference Manual

Offset data and attribute

Offset data is used exclusively with area variables. The value of an offset variable indicates the location of a based variable within an area variable relative to the start of the area. Because the based variables are located relatively, if the area variable is assigned to a different part of main storage, the offset values remain valid.

Offset variables do not preclude the use of pointer variables within an area.

Read syntax diagramSkip visual syntax diagram>>-OFFSET--+-----------------+---------------------------------><
           '-(area-variable)-'
 

The association of an area variable with an offset variable is not permanent. An offset variable can be associated with any area variable by means of the POINTER built-in function (see Locator conversion). The advantage of making such an association in a declaration is that a reference to the offset variable implies reference to the associated area variable. If no area variable is specified, the offset can be used as a locator qualifier only through use of the POINTER built-in function.

Setting offset variables

The value of an offset variable can be set in any one of the following ways:

If no area variable is specified, the offset can be used only as a locator qualifier through use of the POINTER built-in function.

Examples of offset variables

Consider the following example:

  dcl X based(O),
      Y based(P),
      A area,
      O offset(A);

      allocate X;
      allocate Y in(A);

The storage class of area A and offset O is AUTOMATIC by default. The first ALLOCATE statement is equivalent to:

  allocate x in(A) set(O);

The second ALLOCATE statement is equivalent to:

  allocate Y in(A) set(P);

The following example shows how a list can be built in an area variable using offset variables:

  dcl A area,
      (T,H) offset(A),
      1 STR based(H),
        2 P offset(A),
        2 data;

      allocate STR in(A);
      T=H;

    do loop;
      allocate STR set(T->P);
      T=T->P;

·
·
·
end;

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)