[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: Uppercasing Initial charchters.
- Subject: Re: Uppercasing Initial charchters.
- From: Brian Nice <bnice@CCCI.ORG>
- Date: Thu, 6 May 1999 13:21:36 -0400
Oracle has a function called INITCAP that you can use that does just what you
descripbed.
I have done a similar thing with addresses and found, though, that I still
needed to go
through the address line 1 character at a time becuase of exceptions like PO,
RR, NW,
SW, etc... I did the following routine (in this routine the address line is
passed in all caps
and returned first character cap, rest lower case)...
!--set up exceptions for lower case routine. The ~ is a separator just in case
some combination
!--of exception characters make up some weird word.
!--directions NE, SE,.. Rural Route RR, and Post Office PO
let $exception = '~NE~SE~NW~SW~RR~PO'
BEGIN-PROCEDURE lower-case(:$addrLine)
let $line = ''
let #lineLength = length($addrLine) + 1
let $firstChar = 'Y'
let #i = 1
!--go one beyond the length of the line so the last 'word' can be checked
while #i <= #lineLength
let $char = cond(#i = #lineLength, ' ', substr($addrLine,#i,1))
!--get everything but spaces, letters, numbers, symbols...
if $char <> ' '
if $firstChar = 'Y'
let $word = $word || $char
let $firstChar = 'N'
else
let $word = $word || lower($char)
end-if
else
!--break in a word or the last word
!--could have a number or letter by itself, don't worry about these
let #loc = -1
if length($word) > 1
let $upperWord = upper($word)
find $upperWord in $_exception 0 #loc
if #loc <> -1
let $word = $upperWord
end-if
end-if
let $line = $line || $word || cond(#i = #lineLength, '', ' ')
let $firstChar = 'Y'
let $word = ''
end-if
add 1 to #i
end-while
let $addrLine = $line
END-PROCEDURE
Hope that helps
Brian
>>> Chad Slattery <Chad.Slattery@CSCLAC.IRLGOV.IE> 05/06/99 10:40AM >>>
Unix KSH
Oracle 6
sqr 2.5 (upgrading to NT and sqr3 soon)
Hi all,
Im taking name and address' off a table and inserting them into a mail
merge. I need to upper case the initials on each field. I have the below
procedure which will work, but does anyone have anything easier as I have
to put each field into the procedure and take it back out again?
Is there some sort of initcaps function in sqr 2.5? There doesnt seem to
be anything in the manual.
Many thanks,
Chad.
---------------------------------------------------------------------------
--------------------------------------------------
I move name to incaps as the passed in field and move it back again when it
comes out.
I do the same for all address fields.
begin-procedure init_names
let #len = length($incaps)
let #rest = #len - 1
extract $initial from $incaps 0 1
extract $rest from $incaps 1 #rest
uppercase $initial
let $incaps = $initial
lowercase $rest
let #i = 0
while #i < #rest
extract $more from $rest #i 1
if $more = ' '
concat $more with $incaps
add 1 to #i
extract $more from $rest #i 1
uppercase $more
concat $more with $incaps
else
concat $more with $incaps
end-if
add 1 to #i
end-while
end-procedure