IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Inspect verb usage


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Priti_S

New User


Joined: 18 Feb 2009
Posts: 8
Location: pune

PostPosted: Thu Feb 26, 2009 9:36 am
Reply with quote

HI,

I have the following requirement

I have an input string as ABC XYZ ABC ZZZ

I want the ouput string to be ABC XYZ ZZZ

How can i eliminate the repeating ABC in the above input string using inspect verb

TIA,
PS
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Feb 26, 2009 10:35 am
Reply with quote

Hello and welcome to the forum,

Quote:
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.
Back to top
View user's profile Send private message
Priti_S

New User


Joined: 18 Feb 2009
Posts: 8
Location: pune

PostPosted: Thu Feb 26, 2009 1:17 pm
Reply with quote

ABC is just an example... u can consider another string as

scott michelle v scott bond scott....

basically i want to count the number of scott repitting in the string...

to be more specific i want to count the number of occurences of the first word(in this case scott) in a string.
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Thu Feb 26, 2009 3:07 pm
Reply with quote

Priti_S,
there is lot of difference in the suggested requirements in your two posts. Going by
Quote:
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.
Code:
Working storage.

 01 PT1 PIC 9(02) VALUE ZEROES.                               
 01 PTEMP-ONE  PIC X(50) VALUE SPACES.                         
 01 PTEMP.                                                     
   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'.
 
Procedure Division.
PERFORM UNTIL SPACES-FOUND OR I= LENGTH OF PTEMP-ONE
IF PTEMP-ONE(I:1)= SPACES                           
   SET SPACES-FOUND TO TRUE                         
ELSE                                               
   MOVE I TO PT1                                   
   MOVE PTEMP-ONE(I:1)  TO PTEMP-TWO(I)             
END-IF                 
COMPUTE I = I + 1   
END-PERFORM         
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.

Hope it helps,
WTF
Back to top
View user's profile Send private message
Priti_S

New User


Joined: 18 Feb 2009
Posts: 8
Location: pune

PostPosted: Thu Feb 26, 2009 5:05 pm
Reply with quote

Thanks ..... bit of changes in the above code... solved my purpose.... icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts STEM usage in REXX CLIST & REXX 14
No new posts z/OS Modules Usage report using SMF 42 DFSORT/ICETOOL 2
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts JCL and TAPE drives: how to maximize ... JCL & VSAM 9
This topic is locked: you cannot edit posts or make replies. regarding COBOL WRITE verb (VB File H... COBOL Programming 9
Search our Forums:

Back to Top