IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

First letter to be caps


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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: 2358
Location: Israel

PostPosted: Fri Feb 24, 2006 4:56 pm
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
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

Global Moderator


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

PostPosted: Fri Feb 24, 2006 5:34 pm
Reply with quote

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

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Fri Feb 24, 2006 8:17 pm
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
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: 2358
Location: Israel

PostPosted: Thu Mar 02, 2006 6:34 pm
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
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: 2358
Location: Israel

PostPosted: Thu Mar 02, 2006 8:21 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts DID ANYONE RECEIVE THE OFFER LETTER F... Mainframe Jobs 0
No new posts Lower case letter is not accepting in... CA Products 3
No new posts Writing first line of work file with ... Java & MQSeries 3
No new posts Convert upper case to lower except fi... DFSORT/ICETOOL 4
No new posts Eazytrieve Letter ----unwanted data i... CA Products 8
Search our Forums:

Back to Top