Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups 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
Author Message
prabs2006
Warnings : 1

Active User


Joined: 12 Jan 2006
Posts: 104

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
References
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 1973
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
Warnings : 1

Active User


Joined: 12 Jan 2006
Posts: 104

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: 3314
Location: Charlotte,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: 1973
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
Warnings : 1

Active User


Joined: 12 Jan 2006
Posts: 104

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: 1973
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
Warnings : 1

Active User


Joined: 12 Jan 2006
Posts: 104

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: 1973
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
Warnings : 1

Active User


Joined: 12 Jan 2006
Posts: 104

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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1