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 Record Not found in AlX but record re... mukun264 COBOL Programming 7 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Display FTP Session Count within TSO Yolanda Harvey TSO/ISPF 3 Fri Mar 10, 2017 10:31 pm
No new posts what is meaning of the number in dcl Martylin PL/I & Assembler 2 Thu Mar 09, 2017 7:18 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am


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