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
 
First letter to be caps

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Fri Feb 24, 2006 4:48 pm    Post subject: First letter to be caps
Reply with quote

Hi all,

I have a reqmt. I need all the first letter of a word (in a sentence) to be caps? H can I do that?

Eg: this is rexx

to be as

This Is Rexx

T & R
Prabs
Back to top
View user's profile Send private message

ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Fri Feb 24, 2006 4:56 pm    Post subject:
Reply with quote

Here is my CAPITAL rexx. It capitalize input, except string in quotes or double quotes:
Code:
/****************************** REXX ******************************** */
/*                                                                    */
/* Name.......: CAPITAL                                               */
/*                                                                    */
/* Function...: Capitalize a string.                                  */
/*                                                                    */
/* Date.......: 04/05/2003.                                           */
/*                                                                    */
/* Author.....: OFER                                                  */
/*                                                                    */
/* Reqirements: -                                                     */
/*                                                                    */
/* Description: Change the start of words to upper-case. All other    */
/*              letters are changed to lower-case.                    */
/*              Call as a function: X = ACPITAL(string)               */
/*                                                                    */
/**********************************************************************/
                                                                       
ARG INPUT                                                               
                                                                       
DQ     = 0                                                             
SQ     = 0                                                             
OUTPUT = ""                                                             
PREV   = ' '                                                           
UPPER  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 '                       
LOWER  = 'abcdefghijklmnopqrstuvwxyz1234567890 '                       
                                                                       
DO I = 1 TO LENGTH(INPUT)                                               
                                                                       
  IF SUBSTR(INPUT,I,1) = "'" THEN                                       
    SQ = SQ + 1                                                         
                                                                       
  IF SUBSTR(INPUT,I,1) = '"' THEN                                       
    DQ = DQ + 1                                                         
                                                                       
  IF DATATYPE(PREV,"M") |,                                             
    (PREV = "'" & (SQ//2 = 0 | DQ//2 = 1)) |,                           
    (PREV = '"' & (SQ//2 = 0 | DQ//2 = 1)) THEN                         
    OUTPUT = OUTPUT||TRANSLATE(SUBSTR(INPUT,I,1),LOWER,UPPER)           
  ELSE                                                                 
    OUTPUT = OUTPUT||TRANSLATE(SUBSTR(INPUT,I,1),UPPER,LOWER)           
  PREV = SUBSTR(INPUT,I,1)                                             
END                                                                     
                                                                       
RETURN OUTPUT                                                           
                                                                       


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

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Fri Feb 24, 2006 5:03 pm    Post subject:
Reply with quote

Thanks Ofer...but dont we have any inbuilt function?

T & R
Prabs
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4650
Location: Raleigh, NC, USA

PostPosted: Fri Feb 24, 2006 5:34 pm    Post subject: Re: First letter to be caps
Reply with quote

Yes, Parse Upper ...
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Fri Feb 24, 2006 8:17 pm    Post subject:
Reply with quote

PARSE UPPER will convert the whole string to uppercase. Prabs was asking about capitalization.

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

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Thu Mar 02, 2006 5:29 pm    Post subject:
Reply with quote

Hi

can you please explain this condition from the above set of code posted by Ofer.

IF DATATYPE(PREV,"M") |,
(PREV = "'" & (SQ//2 = 0 | DQ//2 = 1)) |,
(PREV = '"' & (SQ//2 = 0 | DQ//2 = 1)) THEN

T & R

Prabs
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu Mar 02, 2006 6:34 pm    Post subject:
Reply with quote

This piece of code tells REXX: If we are not at the start of new word, and if we are not in the middle of a constant (bounded by quotes) - then translate to lowercase.

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

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Thu Mar 02, 2006 6:44 pm    Post subject:
Reply with quote

Hi Ofer,

Sorry to bug u again. I can understand from higher level. It will be better if u can explain me explicitly. Thanks

T & R
Prabs
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu Mar 02, 2006 8:21 pm    Post subject:
Reply with quote

I reading the string char by char. When I encounter a quote or double quote, I add 1 to the counter.
The question in the IF says: If the number of quotes is even (that means - we are not in the middle of a constant), then translate to lowercase.

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

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Fri Mar 03, 2006 10:00 am    Post subject:
Reply with quote

Thanks a lot buddy. I got it
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DID ANYONE RECEIVE THE OFFER LETTER F... anupam das Mainframe Jobs 0 Thu Feb 13, 2014 12:55 pm
No new posts Lower case letter is not accepting in... senthilnathanj CA Products 3 Mon Oct 07, 2013 3:35 pm
No new posts Writing first line of work file with ... cooolguyin Java & MQSeries 3 Wed Jul 13, 2011 2:55 am
No new posts Convert upper case to lower except fi... Skolusu DFSORT/ICETOOL 4 Tue Apr 26, 2011 7:05 pm
No new posts Eazytrieve Letter ----unwanted data i... phani.mf2011 CA Products 8 Tue Apr 26, 2011 2:05 pm

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