Login
`
Templates, Tools and Utilities
|
||
Icetips Article
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, 3:46 am This article has been viewed 35202 times.
|
|