<lex level restriction part>
── FOR ─┬─<pointer identifier>─┬───────────────────────────────────────┤
└─<array identifier>───┘A global pointer pointing to a local array would access an invalid portion of memory if the local array is deallocated. To avoid this situation, any construct that could result in a pointer pointing to an array declared at a higher lexical (lex) level than that at which the pointer is declared is disallowed by the compiler. Such an assignment is called an up-level pointer assignment.
An explicit up-level pointer assignment such as the following results in a syntax error, because the locally declared array LOCALARRAY might be deallocated, leaving the global pointer GLOBALPOINTER pointing at an invalid memory location:
GLOBALPOINTER := POINTER(LOCALARRAY)
A potential up-level pointer assignment such as the following also results in a syntax error, because the local pointer LOCALPOINTER can point to a locally declared array:
GLOBALPOINTER := LOCALPOINTER
Of course, LOCALPOINTER can point to an array declared at a lex level equal to or less than that at which GLOBALPOINTER is declared (in which case up-level assignment would not occur). However, because there is no way for the compiler to determine where LOCALPOINTER will be pointing when the assignment is executed, such potential up-level pointer assignments are not allowed.
The lex level restriction part causes assignments to the declared pointer to be restricted so that the pointer can be used to assign values to pointers declared at lower lex levels. The lex level restriction part specifies that, for up-level pointer assignment checking, the compiler is to treat the pointer being declared as if it were declared at the same lex level as the pointer or array whose identifier follows the FOR. For example, the following declaration declares a pointer LOCALPOINTER that can point only to arrays declared at lex levels equal to or less than the lex level at which GLOBALPOINTER is declared:
POINTER LOCALPOINTER FOR GLOBALPOINTER
Because assignments to LOCALPOINTER are restricted by the lex level restriction part in the preceding declaration, an assignment such as the following one cannot result in an up-level pointer assignment, and therefore is allowed by the compiler:
GLOBALPOINTER := LOCALPOINTER
The lex level restriction part is not allowed in the formal parameter part or the global part of a PROCEDURE declaration.

