Name case converter (OpenInsight 32-Bit)
At 23 MAR 2007 02:23:16AM Barry Stevens wrote:
Does anyone have a namecap converter that works for:
MacDonald , McDonald, O'Donald etc etc
At 23 MAR 2007 07:55AM Dave Harmacek wrote:
Here's a start for you:
SUBROUTINE KHNAMECAP(ARG)
*
* ARG is not used, but is required for MERGE.
*
* Capitalizes then first letter of each word, where each word
* is separated by anything but the alphabet. This differs from NAMECAP
* which separates words by only spaces or value marks.
*
* Author: Krakow & Harmacek, Inc. Sometime in the 80's
*
* The string to change will be in @ANS
*
* So, this does a good job with O'Brien and Smart-Comm, but not for Al's
*
D=@ANS
* Each alphabetic character in variable D will become a space so we can
* later insert them in the result.
CONVERT @UPPER.CASE:@LOWER.CASE TO SPACE(52) IN D
DELIMS=D
* Find every delimiter but the space. Convert each one to a space in
* the variable that we will submit to NAMECAP.
CONVERT " " TO "" IN DELIMS
CONVERT DELIMS TO SPACE(LEN(DELIMS)) IN @ANS
CALL NAMECAP()
* If a non-space character is found, place it in the result.
N=1
LOOP
S=DN,1UNTIL S EQ ''IF S NE ' ' THEN @ANSN,1=SN += 1REPEAT
* The result is in @ANS.
RETURN
Dave
At 23 MAR 2007 01:06PM Richard Hunt wrote:
Have you looked at the NAMECAP function.
result=Namecap(source_string)
At 24 MAR 2007 01:42AM Barry Stevens wrote:
Cool, thanks
At 24 MAR 2007 02:25AM Barry Stevens wrote:
now it works - for O'Brien — I will add code for Mc Mac, I was hoping someone might have covered any I missed.
CONVERT @UPPER.CASE:@LOWER.CASE TO SPACE(104) IN D
.
.
.
CALL NAMECAP(@ANS)
At 24 MAR 2007 03:17AM Barry Stevens wrote:
Sorry guys, I have accidently found one as I was savingDave's as bsbsnamecap
For what it is worth here it is: I thisnk the guts of it came from someone esle many many years ago
subroutine bsbsnamecap(conv.type, in.value, subr.branch, return.value)
declare subroutine msg
equ true$ to 1
equ false$ to 0
equ otherwise$ to 1
equ null$ to ''
equ space.char to ' '
equ period to '.'
return.value=in.value
*if conv.type=OCONV" then
no.of.words =1
convert @upper.case to @lower.case in return.value
delimiter= '
gosub Check.words
no.of.real.words=no.of.words ;* store this value for later use.
delimiter=.'
gosub Check.words
delimiter=-'
gosub Check.words
delimiter="
gosub Check.words
* checking for 'mac' and 'mc'*
convert ' ' to @fm in return.value
for i=1 to no.of.real.words
begin casecase return.value[i]1,3 _eqc 'mac' ; j=3case return.value[i]1,2 _eqc 'mc' ; j=2case otherwise$ ; j=0end caseif j thennext.letter=return.value[i]j+1,1convert @lower.case to @upper.case in next.letterreturn.value[i]=return.value[i]1,j:next.letter:return.value[i]j+2,200endnext i
convert @fm to ' ' in return.value
If Return.value=Unknown" Then Return.value=UnKnown"
*end else
*convert @lower.case to @upper.case in return.value
*end
return
!* Check.words: !*
if count(return.value,delimiter) or (delimiter= ') then
convert delimiter to @fm in return.valueno.of.words=count(return.value,@fm) + (return.value#null$)for i=1 to no.of.wordsword=return.value[i]if word # null$ thenfirst.letter=word1,1convert @lower.case to @upper.case in first.letterreturn.value[i]=first.letter:word2,len(word)-1endnext iconvert @fm to delimiter in return.valueend
return
At 26 MAR 2007 10:49AM Gerald Lovel wrote:
The free ATLAS Framework (see atlaswares.com) contains CNV_CASE, which handles McDonald, McDonald's, O'Leary, etc. An updated version will be released with OI 8.0, as some subtle issues are fixed now.
Gerald
At 27 MAR 2007 10:35AM John Scutt wrote:
You will need to allow for surnames that begin with Mac, but are not Scottish. Machin is one to watch out for, but there are a few others that I cannot remember.
At 27 MAR 2007 02:54PM Karen Oland wrote:
That's why we just store in mixed case (and have for 15 years or better) and only upcase when needed for govt reports.
At 27 MAR 2007 06:14PM Barry Stevens wrote:
Thanks,
At 28 MAR 2007 09:32AM Gerald Lovel wrote:
ACRONYMS, MacCapitals and van der Dutchnames cannot be capitalized by any automatic conversion. For this reason, the CNV_CASE routine does not alter entries which include capitals already. In other words, only entries typed in all lower case are namecapped; mixed case is accepted as typed.