[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Uppercasing Initial characters.



I have one similar to this in one of my libraries that also has code for
pattern checking so that if you have things like the following:

        Patterns: DEL=DeL:DE=de:III=III:II=II:LAR=LaR

         Inbound: TONY DELIA
        Outbound: Tony DeLia

         Inbound: CHARLES DE GAUL
        Outbound: Charles de Gaul

         Inbound: JOHNNY LARUE
        Outbound: Johnny LaRue

         Inbound: WINCHESTER,CHARLES EMERSON III
        Outbound: Winchester,Charles Emerson III

The patterns are checked in the order that they are defined, and are only
checked when a "new word" (following specific characters) is started.  If a
pattern match is found, the pattern is applied, and pattern checking stops.

You can get the library from my web site if you want http://www.axis-dev.com
and it is in the "Library" section, file ADLIB001.ZIP.

.....Rob
_________________________________________________
Robert Goshko <mailto:robert.goshko@axis-dev.com>
Owner
Axis Developments
System Consulting Services
Sherwood Park, Alberta, Canada
http://www.axis-dev.com/


-----Original Message-----
From: Discussion of SQR, SQRIBE Technologies's database reporting
language [mailto:SQR-USERS@list.iex.net]On Behalf Of Tony DeLia
Sent: Thursday May 6, 1999 10:03 AM
To: Multiple recipients of list SQR-USERS
Subject: Re: Uppercasing Initial charchters.


Hi Chad,

   Here's something I posted to the group in January...

   See [Re: Name Format Validation] - Tony DeLia 01/12/1999

My routine is streamlined and is not database specific (or SQR version
specific)... I also have a name validation routine under the same
thread...

Assuming the variable $name contains 'SMITH,JOE R'...

do ULcase-Format ($name)

$name will now contain... 'Smith,Joe R'

I use it for various 'case' requirements... addresses for example...

'NEW YORK'         converts to 'New York'...
'123 SOUTH STREET' converts to '123 South Street'...
'12 N.LAKE ST.'    converts to '12 N.Lake St.'

It simply forces any character to uppercase that follows a blank, comma
or period (add additional symbols if needed)... The primary use for this
routine is converting Mainframe data to PeopleSoft...

Here's the routine...

!**********************************************************************
!*       Upper/Lower Case Formatting                                  *
!**********************************************************************

begin-procedure ULcase-Format(:$ULstring)

let $ULdata      = $ULstring

lowercase $ULdata

let #ULlen       = length($ULdata)
let $ULstring    = ''
let #pos         = 1

let $ULprev      = ' '

while #pos      <= #ULlen

   let $ULchar   = substr($ULdata, #pos, 1)

   if  instr(' ,.',$ULprev,1) > 0
       uppercase $ULchar
   end-if

   let $ULstring = $ULstring || $ULchar
   let $ULprev   = $ULchar
   let #pos      = #pos + 1

end-while

end-procedure

!**********************************************************************

This routine is simple but effective...

                                           -Tony DeLia


Chad Slattery wrote:
>
> 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

--
Tony DeLia
AnswerThink Consulting Group
PeopleSoft Solutions Practice - Delphi Partners
tdelia@erols.com
http://www.sqrtools.com