What is inspect in COBOL ?

Questions by valimasthan

Showing Answers 1 - 9 of 9 Answers

swaroop

  • Oct 10th, 2011
 

It is used to count the number of occurrences of a character in a string. It is used to replace the characters as well..

PKK

  • Dec 9th, 2011
 

Individual characters in a field can be accessed and possibly changed by use of the INSPECT verb.

INSPECT is used with TALLYING option to count designated characters.
eg: INSPECT WS-A
TALLYING WS-COUNT FOR ALL $

INSPECT is used with REPLACING option to change designated characters.
eg: INSPECT WS-B
REPLACING LEADING BY 0

With INSPECT, TALLYING and REPLACING can be used together as well.
eg: INSPECT WS-A
TALLYING WS-COUNT FOR ALL $
REPLACING ALL $ BY *

To convert all uppercase letters to lowercase, INSPECT can be used with CONVERTING. But this doesnt work for all versions of COBOL.

eg: INSPECT WS-NAME
CONVERTING ABCDEFGHIJKLMNOPQRSTUVWXYZ
TO abcdefghijklmnopqrstuvwxyz

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions