Login
`
Templates, Tools and Utilities
|
||
Add a comment to an Icetips ArticlePlease add your comments to this article.
Please note that you must provide both a name and a valid email address in order
for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!
Back to article list Search Articles Add Comment Printer friendly Direct link Par2: Function to proper case a name 2000-08-05 -- Bob Campbell I get Name data from an Oracle database, in the same mess as yours. Here's a
function I wrote to Capitalize the names. It's actually pretty simple.
In the data section embed I put:
B BYTE ! Beginning of word, i.e. the first letter
Ii BYTE ! The name has II suffix, e.g. James Madison II
Mc BYTE ! The name has Mc, e.g. McEnroe
Idx SHORT ! Index or position
In the Process Code embed, I put:
B = TRUE
IF UPPER(SUB(Nam,1,2)) = 'MC'
Mc = TRUE
!MESSAGE('Mc = ' & Mc & '|Nam = ' & Nam,'Proper Case',ICON:Asterisk)
ELSE
Mc = FALSE
END
LOOP Idx = 1 TO LEN(CLIP(Nam))
IF Ii AND Nam[Idx] = 'I'
B = TRUE
END
IF Idx > 1 AND NOT B
Nam[Idx] = LOWER(Nam[Idx])
END
IF Nam[Idx] = '' OR Nam[Idx] = ',' OR Nam[Idx] = '.' OR Nam[Idx] = '-' OR Nam[Idx] = '(' OR Nam[Idx]
= '/'
B = TRUE
!MESSAGE('Idx = ' & Idx,'Proper Case',ICON:Asterisk)
ELSE
B = FALSE
END
IF Mc AND Idx = 2
B = TRUE
END
IF Nam[Idx] = 'I'
Ii = TRUE
ELSE
Ii = FALSE
END
END
!MESSAGE('Nam = ' & Nam,'Proper Case',ICON:Asterisk)
RETURN(Nam)
The prototype is (
Today is November 21, 2024, 6:35 am This article has been viewed 35203 times.
|
|