Previous Topic Next topic Print topic


POINTER Function

Purpose

Returns a pointer value specifying the generation of a based variable in an area.

Syntax

POINTER(o,a)

Abbreviation(s): PTR for POINTER.

Parameters

o is an offset reference that specifies the generation of a based variable in the area identified by a.

Description

If o is the null offset value, the POINTER function returns the null pointer value; otherwise, the value of o must be the offset of some based variable's allocation in an area, but not necessarily in a.

The result returned by the POINTER function is the sum of the offset value, o, plus the address of the beginning of the area, a.

Examples

DECLARE (A, B) AREA;
DECLARE (A1, A2) CHAR(20) BASED; 
DECLARE (P1, P2) POINTER;
DECLARE (O1, O2) OFFSET;

ALLOCATE A1 IN(A) SET(O1);
ALLOCATE A2 IN(A) SET(O2);

B = A;                  /* assign area */

P1 = POINTER(O1, B);    /* address of A1 in B */
P2 = POINTER(O2, B);    /* address of A2 in B */

Restrictions

None.

Previous Topic Next topic Print topic