Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
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
 
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 line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 5 Sat Oct 14, 2017 2:29 am
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts sending email from jcl using the mail... niloyarp JCL & VSAM 5 Tue Oct 10, 2017 12:32 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us