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

Re: Uppercasing Initial charchters.



Tony,
Many thanks for the below procedure, it worked a treat.  I had used the
oracle function 'initcap' on my select but it didn't work on all fields due
to some symbol insertions, I got round it using your
proc and adding the symbols.

regards,
Chad.




Please respond to SQR-USERS@LIST.IEX.NET

To:   Multiple recipients of list SQR-USERS <SQR-USERS@LIST.IEX.NET>
cc:    (bcc: Chad Slattery)

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