[jawsscripts] Re: Making a string title case

  • From: "Dale Leavens" <dleavens@xxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Thu, 4 Mar 2010 22:56:22 -0500

Hello Paul,

How can I use this script? Say I have some text in a Notepad document I want 
to convert with this script then save back to the file?

Do I somehow select the text and how do I then get that into the string for 
the Jaws script to convert.

This looks like something I can use. Thanks for any help.


----- Original Message ----- 
From: "Paul Magill" <magills@xxxxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Saturday, February 27, 2010 6:37 AM
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: