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

Special scenario for String searching in Cobol


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

New User


Joined: 27 May 2008
Posts: 71
Location: USA, CA.

PostPosted: Sun Dec 28, 2008 4:47 am
Reply with quote

Hi All,

Can anyone please help me with a special scenario for string searching.

I have a string like ABCDEFGHIJKLMNOPQRSTUVWXYZ and i have to search this string like when A and D are present but B is not present.
Is there any way in cobol?

Thanks Nitin
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Sun Dec 28, 2008 4:55 am
Reply with quote

Use reference modification on the string. Pseudo code is:

Set count to zero.
Loop from 1 to length of string
If string character = 'A' or 'D'
Add 1 to count
End-if
If string character = 'B'
Subtract 1 from count
End-if
End-loop
If count = 2 do matched logic
Back to top
View user's profile Send private message
Keanehelp

New User


Joined: 27 May 2008
Posts: 71
Location: USA, CA.

PostPosted: Sun Dec 28, 2008 5:23 am
Reply with quote

Thanks man, this seems perfect idea.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Sun Dec 28, 2008 5:34 am
Reply with quote

Good to hear -- let us know if you have any problems with the code.
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 Help with C character vs C string All Other Mainframe Topics 3
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top