ILE COBOL Language Reference

Replacement and Comparison Rules

  1. Arithmetic and logical operators that do not occur as part of an identifier are considered text words and may be replaced only through the pseudo-text option.
  2. When a figurative constant is operand-1, it will match only if it appears exactly as it is specified. For example, if ALL "AB" is specified in the library text, then "ABAB" is not considered a match; only ALL "AB" is considered a match.
  3. Operand-2 is copied in the place of operand-1 unless pseudo-text-2 positioning rules cause the replacement to be inserted in a different area.
  4. Any separator comma, semicolon, and/or space preceding the leftmost word in the library text is copied into the source program. Beginning with the leftmost library text word and the first operand-1 specified in the REPLACING option, the entire REPLACING operand that precedes the keyword BY is compared to an equivalent number of contiguous library text words.
  5. Operand-1 matches the library text if, and only if, the ordered sequence of text words in operand-1 is equal, character for character, to the ordered sequence of library words. For matching purposes, each occurrence of a comma or semicolon separator and each sequence of one or more space separators is considered to be a single space.
  6. If no match occurs, the comparison is repeated with each successive operand-1, if specified, until either a match is found or there are no further REPLACING operands.
  7. Whenever a match occurs between operand-1 and the library text, the associated operand-2 is copied into the source program.
  8. When all operands have been compared and no match is found, the leftmost library text word is copied into the source program.
  9. The next successive uncopied library text word is then considered to be the leftmost text word, and the comparison process is repeated, beginning with the first operand-1. The process continues until the rightmost library text word has been compared.
  10. Comment lines or blank lines occurring in the library text and in pseudo-text-1 are ignored for purposes of matching; and the sequence of text words in the library text and in pseudo-text-1 is determined by the rules for reference format. Comment lines or blank lines appearing in pseudo-text-2 are copied into the resultant program unchanged whenever pseudo-text-2 is placed into the source program as a result of text replacement. Comment lines or blank lines appearing in library text are copied into the resultant source program unchanged with the following exception: a comment line or blank line in library text is not copied if that comment line or blank line appears within the sequence of text words that match pseudo-text-1.
  11. Text words, after replacement, are placed in the source program according to Standard COBOL format rules. For more information about the reference format areas, refer to Reference Format.

    Each text word copied unaltered from the library will start in the same area of the line in the resultant program as it was within the library. As an exception to this rule, however, if a text word that is being copied unaltered starts in Area A within the library, and follows another text word in Area A which is being replaced by text of a greater length, the unaltered text word will begin in Area B if it will no longer fit in Area A.

    Each text word in pseudo-text-2 that is to be placed in the resultant program begins in the same area of the resultant program as it appeared in pseudo-text-2. Each identifier-2, literal-2, and word-2 that is to be placed in the resultant program begins in the same area of the resultant program as the library text that is being replaced.

    +-------------------------------IBM Extension--------------------------------+

  12. COPY REPLACING does not affect the EJECT, SKIP1/2/3, or TITLE compiler-directing statements.

    +----------------------------End of IBM Extension----------------------------+


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]