HP 3000 Manuals

INITIALIZE Statement [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

INITIALIZE Statement 

The INITIALIZE statement sets selected types of data fields to predefined
values.  For example, INITIALIZE can set numeric data to zeros or
alphanumeric data to spaces.

Syntax 

[]
Parameters literal-1 and represent the sending area. identifier-2 identifier-1 represents the receiving area. Description The description of the data item referenced by identifier-1 or any items subordinate to identifier-1 may not contain the DEPENDING phrase of the OCCURS clause. The data description entry for the data item referenced by identifier-1 must not contain a RENAMES clause. Each category stated in the REPLACING phrase must be a permissible category as a receiving operand in a MOVE statement, where the corresponding data item referenced by identifier-2 or literal-1 is used as the sending operand. (See "MOVE Statement", later in this chapter.) The same category cannot be repeated in a REPLACING phrase. An index data item may not be used as an operand in an INITIALIZE statement. Initializing Data Fields Following are rules for initializing data fields: * The keyword following the word REPLACING corresponds to a category of data as defined under "PICTURE Clause" in Chapter 7 of this manual. * INITIALIZE is executed as if a series of moves had been written. The receiving item of each MOVE is always an elementary item even if identifier-1 refers to a group item. When the REPLACING phrase is specified: * If identifier-1 references a group item a move is executed from identifier-2 or literal-1 to each elementary item of identifier-1 that belongs to the category specified by the REPLACING phrase. * If identifier-1 references an elementary item, a move is executed from identifier-2 or literal-1 to identifier-1, if it belongs to the category specified by the REPLACING phrase. The only exceptions are those fields specified in the first two rules below. * Index data items and elementary FILLER data items are not affected by the execution of INITIALIZE. * Any item that is subordinate to a receiving area identifier and contains the REDEFINES clause, or any item that is subordinate to such an item, is not initialized. However, a receiving area identifier may have a REDEFINES clause or be subordinate to a data item with a REDEFINES clause. * When the statement is written without the REPLACING phrase, data items of the categories alphabetic, alphanumeric, and alphanumeric-edited are set to spaces. Data items of the categories numeric and numeric-edited are set to zeros. In this case, the operation is as if each affected data item is the receiving area in an elementary MOVE statement with the indicated source literal (that is, spaces or zeros). * In all cases, the content of the data item referenced by identifier-1 is set to the indicated value in the order of appearance of identifier-1 (left to right) in the INITIALIZE statement. Where identifier-1 references a group item, affected elementary items are initialized in the sequence of their definition within the group. * If identifier-1 occupies the same storage area as identifier-2, the result of the execution of this statement is undefined, even if both identifiers are defined by the same data description entry. Example WORKING-STORAGE SECTION. 01 A. 05 B PIC 999. 05 C REDEFINES B. 10 D PIC X. 10 E PIC XX. : PROCEDURE DIVISION. : INITIALIZE A. INITIALIZE C. INITIALIZE C A. When the INITIALIZE statements in the example above are executed, the data items are initialized as follows: 1. In the first INITIALIZE, B is set to zeroes, while C, D and E are ignored. 2. In the second INITIALIZE, D and E are set to blanks. 3. In the third INITIALIZE, D and E are set to blanks. B is set to zeroes. The net effect is that D and E are set to zeroes.


MPE/iX 5.0 Documentation