The General Form

Following is the general form of the DECLARE statement:

DECLAREd⊂1[,d⊂2 …];

or

DCL d⊂1 [,d⊂2 …];

where each d is:

[k]name a⊂1 a⊂2 … a⊂n 

or

[k](d⊂1[,d⊂2]…)a⊂1 a⊂2 … a⊂n

where k is an optional level number, each a is an attribute, and name is a name to be declared.

Examples:

DECLARE ((A FIXED, B FLOAT) DECIMAL, C BIT) STATIC; 
DECLARE 1 S STATIC, 2 (A FIXED, B FLOAT) INITIAL(0);

These examples illustrate more factored declarations, as indicated by the fact that the DECLARE statements contain parenthetical lists of names. Factored declarations can be transformed into nonfactored declarations by copying the level number and attribute list of the innermost set of parentheses onto each name contained within the parentheses, removing the parentheses, and repeating this process with the next set of parentheses.

After defactoring, the previous examples are:

DECLARE A FIXED DECIMAL STATIC; 
DECLARE B FLOAT DECIMAL STATIC; 
DECLARE C BIT STATIC;
DECLARE 1 S STATIC,
      2 A FIXED INITIAL(0),
      2 B FLOAT INITIAL(0);

Factored declarations, other than as shown in the recommended form (see the section Factored Declarations) are generally more difficult to read than their unfactored equivalents.

If defactoring produces more than one level number for a given name, even if the level numbers are equal, the factored declaration is invalid and causes the Compiler to issue an error message.

Specification of duplicate attributes containing more than a simple keyword is also invalid, even when the attributes are exact duplicates.