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 

Formatting names of people

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


Joined: 15 May 2005
Posts: 2
Topics: 2

PostPosted: Sun Oct 11, 2009 7:50 pm    Post subject: Formatting names of people Reply with quote

Does anyone have a routing to format peoples names into mixed case. eg Changing DAVID RAE to David Rae or DAVID MCRAE to David McRae.

Thanks in advance

David Rae
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Oct 12, 2009 1:11 pm    Post subject: Reply with quote

davidmrae,

Something for you to work on . I wrote it on the fly and you can add exceptions and more rules as per your need.

Germany names that contain "von", "van", and "der" should remain lower case.

Code:

WORKING-STORAGE SECTION.                       
01  WS-NAME                    PIC X(50).       
01  WS-SUB                     PIC S9(04) COMP.
01  WS-CAP                     PIC S9(04) COMP.
01  WS-TALLY                   PIC S9(04) COMP.

1000-CAPITALIZE-WORD.                                           
                                                               
     MOVE +0                   TO WS-CAP                       
                                  WS-TALLY                     
     MOVE FUNCTION LOWER-CASE(WS-NAME (2 :))                   
                               TO WS-NAME(2 : )                 
     INSPECT FUNCTION REVERSE(WS-NAME)                         
             TALLYING WS-TALLY FOR LEADING SPACES               
                                                               
     PERFORM VARYING WS-SUB FROM 2 BY 1                         
       UNTIL WS-SUB > (LENGTH OF WS-NAME - WS-TALLY)           
          PERFORM 1100-SET-WORDS                               
          IF WS-SUB = WS-CAP OR WS-SUB + 2 = WS-CAP             
             MOVE FUNCTION UPPER-CASE(WS-NAME(WS-SUB : 1))     
               TO WS-NAME(WS-SUB :1)                           
             MOVE FUNCTION UPPER-CASE(WS-NAME(WS-CAP : 1))     
               TO WS-NAME(WS-CAP :1)                           
             MOVE +0  TO WS-CAP                                 
          END-IF                                               
     END-PERFORM                                               
     DISPLAY WS-NAME                                           
     .                                                         
1100-SET-WORDS.                                       
     EVALUATE TRUE                                     
         WHEN WS-NAME(WS-SUB : 4 ) = 'von '           
         WHEN WS-NAME(WS-SUB : 4 ) = 'van '           
         WHEN WS-NAME(WS-SUB : 4 ) = 'der '           
              MOVE +0  TO WS-CAP                       
         WHEN WS-NAME(WS-SUB : 3 ) = 'da '             
         WHEN WS-NAME(WS-SUB : 3 ) = 'di '             
         WHEN WS-NAME(WS-SUB : 3 ) = 'de '             
         WHEN WS-NAME(WS-SUB : 3 ) = 'la '             
              MOVE +0  TO WS-CAP                       
         WHEN WS-NAME(WS-SUB : 2 ) = 'mc'             
              COMPUTE  WS-CAP   = WS-SUB + 2           
         WHEN WS-NAME(WS-SUB : 1 ) = ' '               
         WHEN WS-NAME(WS-SUB : 1 ) = '.'               
         WHEN WS-NAME(WS-SUB : 1 ) = '-'               
         WHEN WS-NAME(WS-SUB : 1 ) = "'"               
              COMPUTE  WS-CAP   = WS-SUB + 1           
     END-EVALUATE                                     
     .                                                 


try with the following names
Code:

MOVE   'sue mclean'                    TO WS-NAME 
MOVE   'pamela j maccarthy'            TO WS-NAME 
MOVE   'Mary-anne macintosh'           TO WS-NAME 
MOVE   'beverly d'angelo'              TO WS-NAME 
MOVE   'jake o'neil's'                 TO WS-NAME 
MOVE   'peter o'tull'                  TO WS-NAME 
MOVE   'andrew w'                      TO WS-NAME 
MOVE   'werner von braun'              TO WS-NAME 
MOVE   'john mcnamara'                 TO WS-NAME 
MOVE   'j.r. ewing'                    TO WS-NAME 
MOVE   'leonardo di caprio'            TO WS-NAME 
MOVE   'leonardo da vinci'             TO WS-NAME 
MOVE   'don alejandro de la vega'      TO WS-NAME 
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Tue Oct 13, 2009 9:21 am    Post subject: Reply with quote

Kolusu,

I tried it.... Looks like the only thing that doesn't work is that it doesn't capitalize the first letter of the first name:

before:

edgar j hoover

after:

edgar J Hoover

Thanks.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Oct 13, 2009 9:29 am    Post subject: Reply with quote

tcurrier,

I assumed the input is ALL caps as OP mentioned, So I did not bother Changing it to Upper case. Moreover it is just something to work on as I really did not account all the rules and exceptions

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