[jawsscripts] Re: Making a string title case

Hi,

Below is  a script which calls the function in my previous post.

Using the PC cursor, you manually select/highlight the text to be modified
in the usual way, leaving the cursor at the end of the selected text.

then run the script.  The selected text is deleted, and replaced with the
same text that has had the first letter of each word capitalised.

example:
just sample text for testing, (mr john doe, 24 hilltop st blabla) and more
text...
& after the  script has been run with the text between the parenthesis
selected:
just sample text for testing, (Mr John Doe, 24 Hilltop St Blabla) and more
text...

* you can select all the text in a document with control+A, and the script 
will work, but remember that the FS function TypeString can only handle a 
limited number of characters depending onyour system & the application.

Script SelectedTextMakeProper () ;shift+control+T

VAR

STRING Text

IF NOT IsPCCursor () THEN

SayString ("You must select the text with the PC cursor active, and it must 
now be on the character immediately following the selected text")

RETURN

ENDIF

LET Text = GetSelectedText ()

{delete} ; the application will delete the selected text

Pause ()

TypeString (StringProperNames (Text))

Delay (1) Pause ()

; the unchanged original text remains in the variable, so it can be saved to 
the clipboard

; CopyToClipboard (Text) ; unrem to have the ability to paste back the 
original version with control+V

SayToCursor ()

; or you may wish to use 1 of the following, or something else to confirm 
the task is done

; SayLine ()

; SayString ("done")

EndScript


Regards,
Paul from Aust

----- Original Message ----- 
From: "Dale Leavens" <dleavens@xxxxxxx>


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>


> 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

__________ 
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

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

Other related posts: