View previous topic :: View next topic
|
Author |
Message |
Keanehelp
New User
Joined: 27 May 2008 Posts: 71 Location: USA, CA.
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Keanehelp
New User
Joined: 27 May 2008 Posts: 71 Location: USA, CA.
|
|
|
|
Thanks man, this seems perfect idea. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Good to hear -- let us know if you have any problems with the code. |
|
Back to top |
|
|
|