[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


Previous Contents Index

6.8.19 INITIATE

Function

The INITIATE statement causes the Report Writer Control System (RWCS) to begin processing a report.


report-name

names a report defined by a Report Description entry (RD) in the Report Section of the Data Division.

General Rules

  1. The INITIATE statement does not automatically open a report file. The program must execute either an OPEN OUTPUT or an OPEN EXTEND statement before it can execute an INITIATE statement.
  2. Upon execution of the INITIATE statement, the RWCS sets all sum counters, LINE-COUNTER, and PAGE-COUNTER to zero.
  3. If the INITIATE statement has more than one report-name, the statement executes as if there were a separate INITIATE statement for each report-name.
  4. A program must execute a TERMINATE statement before it can execute another INITIATE statement for the same report-name.

Additional Reference

Section 6.8.42, USE statement

6.8.20 INSPECT

Function

The INSPECT statement counts or replaces occurrences of single characters or groups of characters in a data item.


src-string

is the identifier of a group item or an elementary data item with DISPLAY usage. INSPECT operates on the contents of this data item.

tally-ctr

is the identifier of an elementary numeric data item.

delim-val

is the character-string that delimits the INSPECT operation. Its content restrictions are the same as those for compare-val.

compare-val

is the character-string INSPECT uses for comparison. It is a nonnumeric literal (or figurative constant other than ALL literal) or the identifier of an elementary alphabetic, alphanumeric, or numeric data item with DISPLAY usage.

replace-char

is the one-character item that replaces all characters. Its content restrictions are the same as those for compare-val.

replace-val

is the character-string that replaces occurrences of compare-val. Its content restrictions are the same as those for compare-val.

compare-chars

is the string that contains the individual characters that convert to those in convert-chars. It is the same kind of item as compare-val.

convert-chars

is the string that contains the individual characters to which the characters in compare-chars convert. It is the same kind of item as compare-val.

Syntax Rules

All Formats

  1. If compare-val, delim-val, replace-char, or compare-chars is a figurative constant, it refers to an implicit one-character data item.
  2. A compare-val of an ALL or LEADING phrase, and a CHARACTERS, FIRST, or CONVERTING phrase can have no more than one BEFORE and one AFTER phrase following it.

Format 2

  1. The sizes of the data referred to by replace-val and compare-val must be equal. When replace-val is a figurative constant, its size equals that of the data referred to by compare-val.
  2. When there is a CHARACTERS phrase, the size of the data referred to by delim-val must be one character.

Format 3

  1. A Format 3 INSPECT statement is equivalent to a Format 1 statement followed by a Format 2 statement. Therefore, Syntax Rules 3 and 4 apply to the REPLACING clause of Format 3.

Format 4

  1. The sizes of the data referred to by convert-chars and compare-chars must be equal. When convert-chars is a figurative constant, its size equals that of the data referred to by compare-chars.
  2. The same character cannot appear more than once in the data referred to by compare-chars.

General Rules

All Formats

  1. Inspection includes: (a) comparison, (b) setting boundaries for the BEFORE and AFTER phrases, and (c) tallying or replacing. Inspection starts at the leftmost character position of the src-string data item. It proceeds to the rightmost character position, as described in General Rules 3 to 5.
  2. If src-string, compare-val, delim-val, replace-val, compare-chars, or convert-chars refers to a data item, the INSPECT statement treats the contents of the item according to the category implied by its data description.
    1. For an alphabetic or alphanumeric item---INSPECT treats the data item as a character-string.
    2. For an alphanumeric edited, numeric edited, or unsigned numeric item---INSPECT treats the data item as though:
      • The data item were redefined as alphanumeric.
      • The INSPECT statement were written to refer to the redefined data item. (See General Rule 2a.)
    3. For a signed numeric item---INSPECT treats the data item as though it were moved to an unsigned numeric data item of the same length. It then applies General Rule 2b.
  3. If the size of src-string is zero characters, inspection does not occur.
  4. If the size of compare-val is zero characters, compare-val does not match in any src-string comparison.
  5. If any identifier is subscripted or is a function-identifier, the subscript or function-identifier is evaluated only once as the first operation in the execution of the INSPECT statement.
  6. During inspection of src-string, each matched occurrence of compare-val is:
    1. Tallied (Formats 1 and 3)
    2. Replaced by replace-char or replace-val (Formats 2 and 3)
  7. The comparison operation determines which occurrences of compare-val are tallied or replaced:
    1. INSPECT processes the operands of the TALLYING and REPLACING phrases in the order they appear, from left to right. The first compare-val is compared to the same number of contiguous characters, starting with the leftmost character position in src-string. compare-val and the compared characters in src-string match if they are equal, character for character. Otherwise, they do not match.
    2. If the comparison of the first compare-val does not produce a match, the comparison repeats for each successive compare-val until either:
      • A match results
      • There is no next compare-val

      When there is no next compare-val, INSPECT determines the leftmost character position in src-string for the next comparison. This position is to the immediate right of the leftmost character position for the preceding comparison. The comparison cycle starts again with the first compare-val.
    3. For each match, tallying, replacing, or both occur, as described in General Rules 9 to 17. INSPECT determines the leftmost character position in src-string for the next comparison. This position is to the immediate right of the rightmost character position that matched in the preceding comparison. The comparison cycle starts again with the first compare-val.
    4. Inspection ends when the rightmost character position of src-string has either:
      • Participated in a match
      • Served as the leftmost character position
    5. When the CHARACTERS phrase is present, INSPECT does not perform any comparison on the contents of src-string. The cycle described in General Rules 6a to 6d operates as if:
      • Inspection compares a one-character data item to each character in src-string
      • A match occurs for each comparison
  8. The BEFORE phrase determines the character position in src-string that will be the final leftmost position in the comparison operation.
    1. Comparison occurs on src-string only:
      • From its leftmost character position
      • To, but not including, the first occurrence of delim-val
    2. The position of the first occurrence of delim-val in src-string is determined before the first comparison operation.
    3. If delim-val does not occur in src-string, the comparison operation proceeds as if there were no BEFORE phrase.
  9. The AFTER phrase determines the character position in src-string that will be the first leftmost position in the comparison operation.
    1. Comparison occurs on src-string only:
      • From the character position to the immediate right of the rightmost character position of delim-val's first occurrence
      • To the rightmost position of src-string
    2. The position of the first occurrence of delim-val in src-string is determined before the first comparison operation.
    3. If delim-val is not in src-string, no match occurs, and inspection causes no tallying or replacement.

Format 1

  1. Executing the INSPECT statement does not initialize the value of tally-ctr.
  2. If the ALL phrase is present, the value of tally-ctr is incremented by one for each occurrence of compare-val in src-string.
  3. If the LEADING phrase is present, the value of tally-ctr is incremented by one for each contiguous occurrence of compare-val in src-string. The leftmost occurrence of compare-val must be at the position where comparison begins in the first comparison cycle. Otherwise, no tallying occurs.
  4. If the CHARACTERS phrase is present, the value of tally-ctr is incremented by one for each character matched in src-string (see General Rule 6e).

Format 2

  1. The adjectives ALL, LEADING, and FIRST apply to succeeding BY phrases until the next adjective appears.
  2. If the CHARACTERS phrase is present, each character matched in src-string is replaced by replace-char (see General Rule 6e).
  3. When ALL is present, each occurrence of compare-val in src-string is replaced by replace-val.
  4. When LEADING is present, each contiguous occurrence of compare-val in src-string is replaced by replace-val. The leftmost occurrence of compare-val must be at the position where comparison begins in the first comparison cycle. Otherwise, no replacement occurs.
  5. When FIRST is present, the leftmost occurrence of compare-val in src-string is replaced by replace-val.


Previous Next Contents Index