p is a pointer reference identifying a based variable; a is the area containing the based variable.
DECLARE (A, B) AREA; DECLARE (A1, A2) CHAR(20) BASED; DECLARE (P1, P2) POINTER; DECLARE (O1, O2) OFFSET(A); DECLARE (O3, O4) OFFSET(B); ALLOCATE A1 IN(A) SET(O1); ALLOCATE A2 IN(A) SET(O2); B = A; /* assign area */ P1 = ADDR(O1->A1); /* address of A1 in A */ P2 = POINTER(O2, B); /* address of A2 in B */ O3 = OFFSET(P1, A); /* offset value of A1 - same in A and B */ O4 = OFFSET(P2, B); /* offset value of A2 - same in A and B */
Description
The OFFSET function returns an offset value that is the relative byte offset of a based variable stored within an area variable.
If p is the null pointer value, the OFFSET function returns the null offset value.