Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Find how many times a character occurs in a String

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sowmyasridhar15

New User


Joined: 13 Mar 2008
Posts: 5
Location: Bangalore

PostPosted: Thu Mar 20, 2008 10:25 am    Post subject: Find how many times a character occurs in a String
Reply with quote

Hi

I just want to know if there is any method to find a character in a string.

Example: MUSCATINE##IOWA##USA

I need to know how many times '##' occurs in the string...Please help...
Back to top
View user's profile Send private message

daye.Zheng

New User


Joined: 15 Feb 2008
Posts: 22
Location: China

PostPosted: Thu Mar 20, 2008 10:33 am    Post subject:
Reply with quote

Using inspect!
For example:

INSPECT stringdata TALLYING counter FOR ALL "#'

you can got it.
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 171
Location: Bangalore

PostPosted: Thu Mar 20, 2008 11:25 am    Post subject: Reply to: Find how many times a character occurs in a String
Reply with quote

Its
Code:
INSPECT String-data TALLYING counter FOR ALL '##'.

as he asked for '##'
Back to top
View user's profile Send private message
sowmyasridhar15

New User


Joined: 13 Mar 2008
Posts: 5
Location: Bangalore

PostPosted: Thu Mar 20, 2008 11:37 am    Post subject: Reply to: Find how many times a character occurs in a String
Reply with quote

Hi...

Thank You...STRING worked...
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Mar 20, 2008 8:00 pm    Post subject:
Reply with quote

Hello,

Quote:
STRING worked...
Please post the STRING code that works.
Back to top
View user's profile Send private message
sowmyasridhar15

New User


Joined: 13 Mar 2008
Posts: 5
Location: Bangalore

PostPosted: Tue Mar 25, 2008 11:46 am    Post subject: Reply to: Find how many times a character occurs in a String
Reply with quote

The code that worked was

Code:
INSPECT String-data TALLYING counter FOR ALL '  '.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Tue Mar 25, 2008 12:30 pm    Post subject:
Reply with quote

how nice. magic code!
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Tue Mar 25, 2008 7:43 pm    Post subject:
Reply with quote

Hello,

Quote:
Thank You...STRING worked...

Quote:
The code that worked was

Code:
INSPECT String-data TALLYING counter FOR ALL '  '.


Not to make too fine a point, but the code that worked is an INSPECT rather than some string/unstring operation. Also, the code posted will find spaces rather than #(s) which i believe was the original requirement.

FWIW.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
No new posts How to change a string containing the... chong.zhou TSO/ISPF 6 Tue Aug 29, 2017 4:54 pm
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am
No new posts String after '.' (period) is not copy... balaji81_k SYNCSORT 6 Wed Aug 23, 2017 9:35 pm
No new posts Command to find TMEMBER name for a TPIPE Siva NKK Kothamasu IMS DB/DC 0 Wed Aug 16, 2017 6:08 pm

Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us