Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
Hello and welcome to the forum,
How can i eliminate the repeating ABC in the above input string using inspect verb
Inspect is probably not going to do what you want.
You need to post a more clear definition of what is needed.
Will all of the "pieces" always be 3 bytes? Is there something special about ABC or should all duplicates in a line be removed? What if there are other duplicates? There may be other considerations, but only you would know them.
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
there is lot of difference in the suggested requirements in your two posts. Going by
to be more specific i want to count the number of occurences of the first word(in this case scott) in a string.
You can try the following code - assuming the length of the input string be 50 bytes.
01 PT1 PIC 9(02) VALUE ZEROES.
01 PTEMP-ONE PIC X(50) VALUE SPACES.
02 PTEMP-TWO PIC X(1) OCCURS 1 TO 50 TIMES DEPENDING ON PT1.
01 SPACE-STATUS PIC X(1) VALUE 'N'.
88 NO-SPACE VALUE 'N'.
88 SPACES-FOUND VALUE 'Y'.
PERFORM UNTIL SPACES-FOUND OR I= LENGTH OF PTEMP-ONE
IF PTEMP-ONE(I:1)= SPACES
SET SPACES-FOUND TO TRUE
MOVE I TO PT1
MOVE PTEMP-ONE(I:1) TO PTEMP-TWO(I)
COMPUTE I = I + 1
INSPECT PTEMP-ONE TALLYING N FOR ALL PTEMP(1:PT1)
N should give you the number of occurrences of the first word. You can work around the code two make it more efficient.