HELPLIB.HLB  —  COBOL  PROCEDURE_DIVISION, INSPECT
  The INSPECT statement counts or replaces occurrences of single
  characters or groups of characters in a data item.

1  –  1format TALLYING

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

  Format 1 -

   INSPECT src-string TALLYING

   {
   { tally-ctr FOR
   {

    {
    {            [ { BEFORE }                   ]            }      }
    { CHARACTERS [ { AFTER  } INITIAL delim-val ] ...        } ...  } ...
    { { ALL     } {
    { { LEADING } { compare-val

                   [{ BEFORE }                   ]     }     }      }
                   [{ AFTER  } INITIAL delim-val ] ... } ... } ...  } ...

1.1  –  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.

1.2  –  tally-ctr

  is the identifier of an elementary numeric data item.

1.3  –  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.

1.4  –  delim-val

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

2  –  2format REPLACING

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

  Format 2 -

  INSPECT src-string REPLACING

    { CHARACTERS BY replace-char [{ BEFORE } INITIAL delim-val] ... }
    {                            [{ AFTER  }                  ]     }
    { { ALL     }                                                   } ...
    { { LEADING } { compare-val BY replace-val
    { { FIRST   }

                         [ { BEFORE } INITIAL delim-val ] ... } ... }
                         [ { AFTER  }                   ]     }     }

2.1  –  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.

2.2  –  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.

2.3  –  delim-val

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

2.4  –  replace-char

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

2.5  –  replace-val

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

3  –  3format TALLYING REPLACING

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

  Format 3 -

   INSPECT src-string TALLYING

   {
   { tally-ctr FOR
   {

    {
    {            [ { BEFORE }                   ]           }      }
    { CHARACTERS [ { AFTER  } INITIAL delim-val ] ...       } ...  } ...
    { { ALL     } {
    { { LEADING } { compare-val
    {
                  [{ BEFORE }                   ]     }     }      }
                  [{ AFTER  } INITIAL delim-val ] ... } ... } ...  } ...
   REPLACING

    { CHARACTERS BY replace-char [{ BEFORE } INITIAL delim-val] ... }
    {                            [{ AFTER  }                  ]     }
    { { ALL     }                                                   } ...
    { { LEADING } { compare-val BY replace-val
    { { FIRST   }

                         [ { BEFORE } INITIAL delim-val ] ... } ... }
                         [ { AFTER  }                   ]     }     }

3.1  –  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.

3.2  –  tally-ctr

  is the identifier of an elementary numeric data item.

3.3  –  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.

3.4  –  delim-val

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

3.5  –  replace-char

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

3.6  –  replace-val

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

4  –  4format CONVERTING

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

  Format 4 -

  INSPECT src-string CONVERTING

      compare-chars TO convert-chars

                    [ { BEFORE } INITIAL delim-val ] ...
                    [ { AFTER  }                   ]

4.1  –  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.

4.2  –  delim-val

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

4.3  –  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.

4.4  –  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.
Close Help