A pointer assignment assigns the pointer on the left side of the assignment operator (:=) to point to the location in an array indicated by the expression on the right side of the assignment operator. Such a pointer is then considered initialized and can be used in the REPLACE and SCAN statements for character manipulation.
A pointer cannot be assigned to an array that is at a higher lex level than the pointer. This would create an up level pointer condition, a situation in which the pointer might reference deallocated memory when the program exits from the higher lex level.
<pointer assignment>
──<pointer variable>─┬─ := ─┬─<pointer expression>─┬───────────────────┤
│ └─<null value>─────────┤
└─<pointer update assignment>─┘<pointer variable>
──<pointer identifier>─────────────────────────────────────────────────┤
<pointer update assignment>
──<update symbols>─┬────────┬──────────────────────────────────────────┤
└─<skip>─┘Pointer Variable
A pointer assignment causes the creation of a pointer variable, or copy descriptor, to an array. The pointer variable can be set up with the needed character size by using the POINTER function syntax. For more information, see POINTER Function.
Examples of Pointer Assignments
The following example assigns a pointer named PTS to point to the EBCDIC character in the EBCDIC array EBCDICARAY identified by the subscripted variable EBCDICARAY[5].
PTS := EBCDICARAY[5]
The following example assigns a pointer named PTR to point to the leftmost character position in the first element of the real array REALARAY.
PTR := POINTER(REALARAY)
The following example assigns the pointer PINFO to point to the seventeenth character position after the character position pointed to by the pointer PTR.
PINFO := PTR + 17
The following example assigns the pointer POUT to point to the leftmost character position in the array element identified by INSTUFF[N]. The 4 following the comma indicates that POUT is a hexadecimal pointer and thus points to hexadecimal characters.
POUT := POINTER(INSTUFF[N],4)

