DECLARE statement

The DECLARE statement specifies some or all of the attributes of a name. If the attributes are not explicitly declared and cannot be determined by context, default attributes are applied.

DECLARE statements can be an important part of the documentation of a program. Consequently, you can make liberal use of declarations, even when default attributes suffice or when an implicit declaration is possible. Because there are no restrictions on the number of DECLARE statements, you can use different DECLARE statements for different groups of names. Any number of names can be declared in one DECLARE statement.

Read syntax diagramSkip visual syntax diagramDECLARE,levelname*attributes;
attributes
Read syntax diagramSkip visual syntax diagramdata-attributesalignment-attributesscope-attributesstorage-attributescomplementary-attributes

Abbreviation: DCL

For more information about declaring arrays, structures, and unions, see Arrays, Structures, and Unions.

*
Cannot be used as the name of an INTERNAL or an EXTERNAL scalar or as the name of a level-1 EXTERNAL structure or union unless the EXTERNAL attribute specifies an environment name (see INTERNAL and EXTERNAL attributes).
attributes
The attributes can appear in any order.

All attributes given explicitly for the name must be declared together in a DECLARE statement, except that:

  • Names having the FILE attribute can also be given attributes in an OPEN statement (or have attributes implied by an implicit opening).
  • The parameter attribute is contextually applied by the appearance of the name in a parameter list. A DECLARE statement internal to the block can specify additional attributes.

Attributes of external names, in separate blocks and compilations, must be consistent.

For more information about attributes and the members of the given groups, see Data types and attributes.

level
A nonzero integer. If a level-number is not specified, level 1 is the default for element and array variables. Level 1 must be specified for major structure and union names.
name
Each level-1 name must be unique within a block. For more information about level-1 names, refer to Structures.

Condition prefixes and labels cannot be specified on a DECLARE statement.