View previous topic :: View next topic |
Author |
Message |
Meena Beginner
Joined: 03 Aug 2004 Posts: 20 Topics: 15
|
Posted: Mon Jan 10, 2005 11:03 pm Post subject: Converting to Sentence Case |
|
|
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 |
|
 |
s_shivaraj Beginner

Joined: 21 Sep 2004 Posts: 140 Topics: 14 Location: Chennai, India
|
Posted: Tue Jan 11, 2005 12:19 am Post subject: |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Tue Jan 11, 2005 9:18 pm Post subject: |
|
|
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 |
|
 |
|
|