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
 

 

Count the number of vowels present in an input string

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

New User


Joined: 12 Mar 2007
Posts: 15
Location: Philippines

PostPosted: Tue Mar 20, 2007 2:31 pm    Post subject: Count the number of vowels present in an input string
Reply with quote

hi guys,

i want to count the number of vowels present in an input string, lets say max length of 50. can you give me suggestions on how to do this without overdoing the EVALUATE statement?

thanks in advance...
Back to top
View user's profile Send private message

murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Tue Mar 20, 2007 2:39 pm    Post subject:
Reply with quote

Move your variable into (temp) table and use a perform loop statement. This should do the trick with one if condition.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Tue Mar 20, 2007 2:59 pm    Post subject:
Reply with quote

Try following loop. Improvements welcome! icon_smile.gif
Code:
  MOVE 0 TO VAV-CNT
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > 50
    IF STR(I) = 'A' OR 'a' OR 'E' OR 'e' OR 'I' OR 'i' OR 'O' OR 'o' OR 'u' OR 'U'
    ADD 1 TO VOV-CNT
    END-IF
  END-PERFORM
  DISPLAY VOV-CNT

or you can use INSPECT verb- (Do check the manual for INSPECT , because I am not sure about the syntax here. icon_smile.gif

Code:
  INSPECT STR TALLYING VOV-CNT FOR ALL 'A' , 'a', 'E', 'e', 'I', 'i', 'O', 'o' ,'u','U'
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Tue Mar 20, 2007 3:01 pm    Post subject:
Reply with quote

Correction:
Please read STR(I) as STR(I:1) icon_redface.gif
Back to top
View user's profile Send private message
wicked1925

New User


Joined: 12 Mar 2007
Posts: 15
Location: Philippines

PostPosted: Tue Mar 20, 2007 3:22 pm    Post subject:
Reply with quote

thanks guys...

all the suggestions worked perfectly...oh btw the inspect clause is correct and i think i'm gonna use that for my final code. thanks again.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Tue Mar 20, 2007 4:14 pm    Post subject:
Reply with quote

I know you asked for COBOL, but just for the fun, here is a REXX example:
Code:
/* REXX */                                                             
                                                                       
A        = 'THIS IS AN EXAMPLE OF VOWEL COUNTING REXX'                 
NO_VOWEL = 'BCDFGHJKLMNPQRSTVWXYZ1234567890'                           
B        = LENGTH(STRIP(SPACE(TRANSLATE(A,' ',NO_VOWEL),0)))           
SAY B                                                                   
                                                                       
EXIT                                                                   
                                                                       


O.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Tue Mar 20, 2007 4:43 pm    Post subject:
Reply with quote

Thanks for getting back.
Good luck icon_biggrin.gif
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 How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts CICS Transaction attach count of supp... lind sh CICS 1 Wed Jun 21, 2017 1:33 pm
No new posts Need input in Scheduling Benchwarmer CA Products 5 Tue Jun 06, 2017 1:44 am
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm


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