Previous Topic Next topic Print topic


ANS85 

The INITIALIZE Statement

The INITIALIZE statement provides the ability to set selected data items to specified values.

General Format


*

Syntax Rules

  1. Identifier-1 must be of class alphabetic or alphanumeric or numeric

    ISO2002MF or national or object or pointer.

  2. ISO2002MF For each DATA-POINTER, OBJECT-REFERENCE or PROGRAM-POINTER phrase specified as the category-name in the REPLACING phrase, identifier-2 must be specified.
  3. ISO2002MF For each of the categories data-pointer, object-reference and program-pointer specified in the REPLACING phrase, a SET statement with identifer-2 as the sending operand and an item of the specified category as the receiving operand must be valid. (See the topic The SET Statement.)

    For each of the categories other than data-pointer, object-reference or program-pointer stated in the REPLACING phrase, a MOVE statement with identifier-2 or literal-1 as the sending item and an item of the specified category as the receiving operand must be valid. (See the topic The MOVE Statement.)

  4. If the REPLACING phrase is specified, literal-1 or the data item referenced by identifier-2 is the sending operand.

    ISO2002MF If the REPLACING phrase is not specified, the sending operand is determined according to the general rules of the INITIALIZE statement.

  5. The data item referenced by identifier-1 is the receiving area.
  6. The same category cannot be repeated in a REPLACING phrase.
  7. The description of the data item referenced by identifier-1 or any items subordinate to identifier-1 cannot contain the DEPENDING phrase of the OCCURS clause.

    VSC2 The data item referenced by identifier-1 cannot be variably located, that is, it cannot follow in the same record description an item containing the DEPENDING phrase of the OCCURS clause unless identifier-1 is subordinate to that item with the OCCURS clause.

    MF The data item referenced by identifier-1 can be variably located.

  8. The data description entry for the data item referenced by identifier-1 must not contain a RENAMES clause.
  9. VSC2MF A floating-point data item or literal can be used anywhere a numeric identifier or literal can be specified.
  10. category-list can be one of:
    • ALPHABETIC
    • ALPHANUMERIC
    • ALPHANUMERIC-EDITED
    • BOOLEAN
    • ISO2002MF DATA-POINTER
    • VSC2MF DBCS
    • ISO2002MF NATIONAL
    • ISO2002MF NATIONAL-EDITED
    • NUMERIC
    • NUMERIC-EDITED
    • ISO2002MF OBJECT-REFERENCE
    • ISO2002MF PROGRAM-POINTER

General Rules

  1. The key words in category-name correspond to a category of data as defined elsewhere in this document. (See the topic Class and Category of Data in the chapter Concepts of the COBOL Language.)

    ISO2002MF If ALL is specified in the VALUE phrase it is as if all of the categories listed in category-name were specified.

  2. Whether identifier-1 references an elementary item or a group item, the effect of the execution of the INITIALIZE statement is as though a series of implicit MOVE or SET statements, each of which has an elementary data item as its receiving operand, were executed. The sending-operands of these implicit statements are defined in general rule 4 and the receiving-operands are defined in general rule 3.

    If the category of a receiving-operand is data-pointer, object-reference, or program-pointer, the implicit statement is: SET receiving-operand TO sending-operand

    Otherwise, the implicit statement is: MOVE sending-operand TO receiving-operand.

  3. The receiving-operand in each implicit MOVE or SET statement is determined by applying the following steps in order:
    1. First, the following data items are excluded as receiving-operands:
      1. ISO2002MF Any identifiers that are not valid receiving operands of a MOVE statement - except data items of category data-pointer, object-reference or program-pointer when dialect specified is MF15 or ISO2002.
      2. If the FILLER phrase is not specified, elementary data items with an explicit or implicit FILLER clause.
      3. Any elementary data item subordinate to identifier-1 whose data description entry contains a REDEFINES or RENAMES clause or is subordinate to a data item whose data description entry contains a REDEFINES clause. However, identifier-1 may itself have a REDEFINES clause or be subordinate to a data item with a REDEFINES clause.
    2. Second, an elementary data item is a posible receiving item if either of the following apply:
      1. It is explicitly referenced by identifier-1
      2. It is contained within the group dtat item referenced by identifier-1. If the elementary data items is a table element, each occurrence of the elementary data items is a possible receiving operand
    3. Finally, each possible receiving operand is a receiving operand if at least one of the following is true:
      1. The VALUE phrase is specified, the category of the elementary data item is one of the categories specified or implied in the VALUE phrase, and one of the following is true:
        1. Either the category of the elementary data item is data-pointer, object-reference, or program-pointer.
        2. A data-item format or table format VALUE clause is specified in the data description entry of the elementary data item.
      2. The REPLACING phrase is specified and the category of the elementary data item is one of the categories specified in the REPLACING phrase.
      3. The DEFAULT phrase is specified.
      4. Neither the REPLACING phrase nor the VALUE phrase is specified.
  4. The sending-operand in each implicit MOVE and SET statement is determined as follows:
    1. If the data item qualifies as a receiving-operand because of the VALUE phrase:
      1. ISO2002MF If the category of the receiving-operand is data-pointer or program-pointer, the sending-operand is the predefined address NULL. This requires the INITPTR compiler directive to be set.
      2. ISO2002MF If the category of the receiving-operand is object-reference, the sending-operand is the predefined object reference NULL. This requires the INITPTR compiler directive to be set.
      3. Otherwise, the sending-operand is determined by the literal in the VALUE clause specified in the data description entry of the data item. If the data item is a table element, the literal in the VALUE clause that corresponds to the occurrence being initialized determines the sending-operand. The actual sending-operand is a literal that, when moved to the receiving-operand with a MOVE statement, produces the same result as the initial value of the data item as produced by the application of the VALUE clause.
    2. If the data item does not qualify as a receiving-operand because of the VALUE phrase, but does qualify because of the REPLACING phrase, the sending-operand is the literal-1 or identifier-2 associated with the category specified in the REPLACING phrase.
    3. If the data item does not qualify in accordance with general rules 4a and 4b, the sending-operand used depends on the category of the receiving-operand as follows:
      Receiving operand Figurative constant
      Alphabetic Figurative constant alphanumeric SPACES
      Alphanumeric Figurative constant alphanumeric SPACES
      Alphanumeric-edited Figurative constant alphanumeric SPACES
      Data-pointer Predefined address NULL
      National Figurative constant national SPACES
      National-edited Figurative constant national SPACES
      Numeric Figurative constant ZEROES
      Numeric-edited Figurative constant ZEROES
      Object-reference Predefined object reference NULL
      Program-pointer Predefined address NULL
  5. In all cases, the content of the data item referenced by identifier-1 is set to the indicated value in the order (left to right) of the appearance of identifier-1 in the INITIALIZE statement. Within this sequence, where identifier-1 references a group item, affected elementary items are initialized in the sequence of their definition in the group. For a variable-occurrence data item, the number of occurrences initialized is determined by the rules of the OCCURS clause for a receiving data item.
  6. If identifier-1 occupies the same storage area as identifier-2, the result of the execution of this statement is undefined, even if they are defined by the same data description entry. (See the topic Overlapping Operands in the chapter Procedure Division.)
Previous Topic Next topic Print topic