Give example of Inspect TALLYING / BEFORE INTIAL / AFTER INITIAL. In which situation will use this in COBOL?

We have different type of Inspect verb
1.counting INSPECT.
2.replacing INSPECT.
3.combined INSPECT.
4.converting INSPECT.
Give example of any Inspect verb which you know.

Questions by gilbat82   answers by gilbat82

Showing Answers 1 - 15 of 15 Answers

Hi,

var1 = 'abc sarath pqrs sawanth xyz'  

INSPECT var1 TALLYING count1 FOR ALL 'S'
  BEFORE INITIAL 'sarath' AFTER 'sawanth'
end-inspect.

sol: count1 = 1

This is used to tally the occurance of a character or group of characters in data field.

Regards,
~SS~

  Was this answer useful?  Yes

For Replacing:

var1 = 'abc pqrs xyz'

INSPECT var1 REPLACING CHARACTERS BY 'p'  BEFORE INITIAL 'abc' AFTER INITIAL 'xyz'
end-inspect.

Sol: var1 = 'abc pppp xyz'

  Was this answer useful?  Yes

Manikandan D

hi sarath your answer was correct but u made one minor mistake ,

for counting inspect

ex:
        var1 = 'abc tree pqrs leaf xyz'

       count1 = inspect var1 tallying count1 for all 's' before initial 'leaf' after initial 'tree'.

ans:
        count1 = 1.

  Was this answer useful?  Yes

maddy5981

  • Nov 16th, 2009
 

INSPECT word TALLYING count FOR LEADING “L” BEFORE INITIAL “A”, count-1 FOR
LEADING “A” BEFORE INITIAL “L”.
Where word = LARGE, count = 1 and count-1 = 0.
Where word = ANALYST, count = 0 and count-1 = 1.
INSPECT word TALLYING count FOR ALL “L”, REPLACING LEADING “A” BY “E” AFTER
INITIAL “L”.
Nucleus
7830 7709–000 2–103
Where word = CALLAR, count = 2 and word = CALLER.
Where word = SALAMI, count = 1 and word = SALEMI.
Where word = LATTER, count = 1 and word = LETTER.
INSPECT word REPLACING ALL “A” BY “G” BEFORE INITIAL “X”.
Where word = ARXAX, word = GRXAX.
Where word = HANDAX, word = HGNDGX.
INSPECT word TALLYING count FOR CHARACTERS AFTER INITIAL “J” REPLACING ALL “A”
BY “B”.
Where word = ADJECTIVE, count = 6 and word = BDJECTIVE.
Where word = JACK, count = 3 and word = JBCK.
Where word = JUJMAB, count = 5 and word = JUJMBB.
INSPECT word REPLACING ALL “X” BY “Y”, “B” BY “Z”, “W” BY “Q” AFTER INITIAL
“R”.
Where word = RXXBQWY, word = RYYZQQY.
Where word = YZACDWBR, word = YZACDWZR.
Where word = RAWRXEB, word = RAQRYEZ.
INSPECT word REPLACING CHARACTERS BY “B” BEFORE INITIAL “A”.
word before: 1 2 X Z A B C D
word after: B B B B B A B C D

abhi7878

  • Jan 14th, 2010
 

F F F
F A F
F F F
F Q F
F F Z

INSPECT StringData
REPLACING ALL "F" BY "G"
AFTER INITIAL "A"
BEFORE INITIAL "Q".

F F F
F A G
G G G
G Q F
F F Z

In previours answers before & after were not in the correct place in others words in place of before after was written. above is the best simple example

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