INITIALIZE Statement
The INITIALIZE
statement sets data items or categories of data items to prescribed values.
General Format:
INITIALIZE { data-1 } … [ WITH FILLER ]
[REPLACING {initialize_category} DATA BY identifier-1 }... ]
Where initialize_category
is one of the following:
ALPHABETIC
ALPHANUMERIC
NUMERIC
ALPHANUMERIC-EDITED
NUMERIC-EDITED
NATIONAL
Syntax:
data-n
is a data item.identifier-n
is a data element, literal, or data returned from a function call.
General Rules:
- The
INITIALIZE
statement can be used to target data elements or classes of data elements. Theinitialize-category
Classes of data elements that are recognized by theINITIALIZE
statement are:ALPHABETIC
ALPHANUMERIC
NUMERIC
ALPHANUMERIC EDITED
NUMERIC EDITED
NATIONAL
For more information on Picture Catagories, see the Picture Data Categories section.
- The default behavior of the
INITIALIZE
verb is to initialize Alphabetic, Alphanumeric, Alphanumeric Edited, and National data items toSPACES
, and Numeric and Numeric-Edited data items toZERO
. - If a group item is initialized which contains a mixture of alphanumeric, numeric, and national data types, each data type will be initialized according to the default behaviours of COBOL-IT.
- If the
REPLACING
clause is used, the impliedMOVE
is evaluated by the compiler tovensure that it is valid. - The following data items should not be targets of the
INITIALIZE
verb:- Data items containing an
OCCURS DEPENDING ON
clause. - FILLER data items, unless the
WITH FILLER
clause is present. - Data items with a
REDEFINES
clause. - Data items described as
USAGE INDEX
- Data items containing an
- The following compiler configuration file entries affect the behavior of the
INITIALIZE
statement. See Compiler and Runtime Reference Manual for complete details.initialize-to-value:[yes/no]
initialize-fd:[yes/no]
initialize-filler:[yes/no
initialize-pointer:[yes/no]
Code Sample:
IDENTIFICATION DIVISION.
PROGRAM-ID. INITIALIZE-1.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 DUMMY PIC X.
PROCEDURE DIVISION.
MAIN.
*INITIALIZE { TARGET } … [ WITH FILLER ]
*[REPLACING {INITIALIZE-CATEGORY} DATA BY VALUE }... ]
*
*WHERE INITIALIZE-CATEGORY IS ONE OF THE FOLLOWING:
*
*ALPHABETIC
*ALPHANUMERIC
*NUMERIC
*ALPHANUMERIC-EDITED
*NUMERIC-EDITED
*NATIONAL
INITIALIZE DUMMY.
INITIALIZE DUMMY WITH FILLER.
INITIALIZE DUMMY
REPLACING ALPHABETIC DATA BY "Z"
ALPHANUMERIC DATA BY "Y"
NUMERIC DATA BY 0
ALPHANUMERIC-EDITED DATA BY "X"
NUMERIC-EDITED DATA BY "W"
NATIONAL DATA BY "V".
DISPLAY "INITIALIZE-1 FINISHED!" LINE 10 COL 10.
ACCEPT DUMMY LINE 10 COL 35.
STOP RUN.