[jawsscripts] Re: Making a string title case

  • From: "Michael" <mike_sharp@xxxxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Sun, 28 Feb 2010 08:41:52 -0000

Paul,

This works excellently and is just what I need.
Thanks very much for sharing.

Regards

Mike

--------------------------------------------------
From: "Paul Magill" <magills@xxxxxxxxxxx>
Sent: Saturday, February 27, 2010 11:37 AM
To: <jawsscripts@xxxxxxxxxxxxx>
Subject: [jawsscripts] Making a string title case

> Hi Michael,
>
> Below is a function I use at work for this purpose.  I took a different
> approach to the problem.
>
> It may suit your needs.
>
>
> String Function StringProperNames (string InString)
>
> ; to convert a string containing names so that the first letter of each 
> name
> is upper case, & the remainder is lower case
>
>
> VAR
>
> INT Position, INT EndPosition, INT PreviousCharWasLetter,
>
> STRING TempString, STRING CurrentChar
>
> LET InString = StringLower (InString)
>
> LET Position = 1
>
> LET EndPosition = StringLength (Instring)
>
> LET PreviousCharWasLetter = False
>
> LET TempString = " " ;Space ; to prevent numbers being numerically added. 
> is
> removed
> before return
>
> While (Position <= EndPosition)
>
> LET CurrentChar = SubString (InString, Position, 1)
>
> If (CurrentChar >= "a") && (CurrentChar <= "z") THEN ; current char is a
> letter
>
> IF PreviousCharWasLetter THEN ; this letter is not the first letter of the
> word
>
> LET TempString = TempString + CurrentChar ; remains lower case
>
> ELSE ; this letter is the first letter of the word as the previous char 
> was
> not a letter
>
> LET TempString = TempString + StringUpper (CurrentChar)
>
> ENDIF ; PreviousCharWasLetter
>
> LET PreviousCharWasLetter = True ; set true so next cycle knows this
>
> ELSE ; current character is not a letter
>
> LET TempString = TempString + CurrentChar
>
> LET PreviousCharWasLetter = False
>
> ENDIF; current character is a letter
>
> LET Position = Position + 1
>
> EndWhile ; not at end of string
>
> RETURN (stringChopLeft (TempString, 1))
>
> EndFunction
>
> Regards,
> Paul from Aust
>
>
> ----- Original Message ----- 
> From: "Michael" <mike_sharp@xxxxxxxxxxxxx>
>
>
> I'm afraid I have another problem with this script in that it does not
> appear to like numbers within the string. For example, if the string is an
> address "24 THE GRANGE" it will convert the uppercase text to title case 
> but
> erase the 24, replacing it with a space.
> Any ideas why it will not work with numbers?
>
> Mike
>
> __________
> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>
> View the list's information and change your settings at
> //www.freelists.org/list/jawsscripts
>
> 
__________ 
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

Other related posts: