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 Usergroups 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: 6967
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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts the use of 'B3'x character in a panel Pedro TSO/ISPF 1 Thu Feb 16, 2017 3:09 am


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