The meaning of a name is normally determined by its declaration. However, in some cases a name can be implicitly declared by the context in which it is used. (For more information, see the sections Compiler-supplied Defaults and DEFAULT .) The declaration of a name consists of a user-specified identifier and the attributes of that name.
Open PL/I permits two kinds of explicit declarations: the DECLARE statement and the label prefix.
The DECLARE statement declares the names of files, variables, and external procedures. A DECLARE statement can appear anywhere within the program, except as part of a compound statement. Regardless of where it appears, DECLARE is not an executable statement and has no effect except to establish the meaning of names.
Examples:
DECLARE F FILE; DECLARE A(5) FLOAT; DECLARE (I,J,K) FIXED BINARY(15);
In the previous examples, F is declared as the name of a file constant; A is declared as a floating-point array variable; and I, J, and K are declared as integer variables.
A label, also called a label prefix, is a user-specified identifier that names a statement so that it can be referenced elsewhere in your program. The label comes before the statement and is terminated with a colon (:).
Examples:
F: FORMAT(F(8,2),A(5)); P: PROCEDURE; L: READ FILE(F) INTO(X);
In these examples, F is declared as a format name, P as a procedure name, and L as a statement label.
Labels can appear on all Open PL/I statements except DECLARE statements, target statements of ON statements (called ON-units), ELSE or THEN clauses in IF statements, and WHEN or OTHERWISE clauses in SELECT statements.