MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Converting to Sentence Case

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Meena
Beginner


Joined: 03 Aug 2004
Posts: 20
Topics: 15

PostPosted: Mon Jan 10, 2005 11:03 pm    Post subject: Converting to Sentence Case Reply with quote

is there any function in cobol which can convert any string to Sentence Case.
Eg: if my string is "good day" i want the output as "Good Day"

Thanks
Meena
Back to top
View user's profile Send private message
s_shivaraj
Beginner


Joined: 21 Sep 2004
Posts: 140
Topics: 14
Location: Chennai, India

PostPosted: Tue Jan 11, 2005 12:19 am    Post subject: Reply with quote

Meena,
If i am right, i didnt think so there is any function for that. You need to write a loop which can check for the start of a word ( char aftetr a space ) and convert correspondingly.
_________________
Cheers
Sivaraj S

'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity'
Back to top
View user's profile Send private message AIM Address
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Tue Jan 11, 2005 9:18 pm    Post subject: Reply with quote

Meena,

Try this

Code:

WORKING-STORAGE SECTION.                       
                                               
01  WS-LWC             PIC X(26) VALUE         
    'abcdefghijklmnopqrstuvwxyz'.               
01  WS-UPC             PIC X(26) VALUE         
    'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.               
                                               
01 WS-TEXT             PIC X(30).               
01 WS-SUB              PIC S9(04) COMP VALUE 2. 
                                               
PROCEDURE DIVISION.                             

                                                         
    MOVE 'good boy' TO WS-TEXT                           

    IF WS-TEXT(1 : 1) IS ALPHABETIC                       
       INSPECT WS-TEXT(1 : 1) CONVERTING WS-LWC TO WS-UPC
    END-IF                                               
                                                         
    PERFORM VARYING WS-SUB FROM WS-SUB BY 1 UNTIL         
     WS-SUB > LENGTH OF WS-TEXT                           
         IF WS-TEXT (WS-SUB :1) = SPACE                   
            IF WS-TEXT(WS-SUB + 1:1) Is AlPHABETIC       
               INSPECT WS-TEXT(WS-SUB + 1: 1)             
                       CONVERTING WS-LWC TO WS-UPC       
            END-IF                                       
         ELSE                                             
            CONTINUE                                     
         END-IF                                           
    END-PERFORM
                                         
    DISPLAY WS-TEXT                                       

    GOBACK.                                               



Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group