[jawsscripts] Re: String question
- From: "Huskins, Wayne" <Wayne.Huskins@xxxxxxxxxxxxx>
- To: <jawsscripts@xxxxxxxxxxxxx>
- Date: Thu, 22 Nov 2007 08:29:46 -0500
Each iteration of the line
let line = stringChopLeft (line, StringLength (StringSegment (line, "
",1))+1)
Removes the left most word from the line
I will try to explain the line of code from the middle working
outwards.
1. I am using stringSegment to get the first word of the line.
String segment takes 3 parameters
The first is the text to be handled, in this case the line of text.
The second parameter is the delimiter, in this case " " a space
And the third parameter is a number representing the string segment I am
looking for, the first word on the line or 1
stringSegment returns the left most word on the line.
2. We then use stringLength to get the length of the result from
stringSegment
I.E. the length of the first word on the line
3. We then add 1 to the value from stringLength to take into
consideration the space following the word.
4. we then use stringChopLeft to remove the left most word from the line
plus the space
5. the final result of the line is that line now equals the original
line minus the left most word and the following space.
To remove additional words from the line in question, simply repeat the
line of code as many times as required.
You could of course put this into a loop to repeat x times
Eg. To remove 3 words
Var
Int x
Let x = 3
While x > 0 && !isKeyWaiting()
;the purpose of !isKeyWaiting is a safety for the loop just in case we
screw it up and
;need a way to stop the loop. If we do something wrong in the loop and
need a way to break out pressing a key stops the loop.
;! Being a not
let line = stringChopLeft (line, StringLength (StringSegment (line, "
",1))+1)
;this if should handle a situation where there are more than one space
together
If StringSegment (line, " ",1) > "" then
Let x = x - 1
Else
stringchopLeft(line,1)
Endif
;this if is a safety in case we have a blank line
If stringIsBlank(line) then
Let x = 0
endif
Endwhile
;the loop will run 3 times thus chopping 3 words from the line the final
result is line being 3 words shorter
Please note I have not compiled the above code with the loop and have
not tested it so I will not guarantee that it works in all situations.
If you use the loop and jaws stops talking or freezes up, pressing a key
should break out of the loop.
You could also create a function which you could call as necessary
String function removeLeftWordsFromLine(string line, int x)
While x > 0 && !isKeyWaiting()
let line = stringChopLeft (line, StringLength (StringSegment (line, "
",1))+1)
If StringSegment (line, " ",1) > "" then
Let x = x - 1
Else
stringchopLeft(line,1)
Endif
If stringIsblank(line) then
Let x = 0
endif
Endwhile
Return line
Endfunction
You could use the function as follows to speak the shorter line
;x is the number of words to remove (e.g. 3)
Saystring(removeLeftWordsFromLine(getline(),3)
Hope this helps
W
-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx]
Sent: November 22, 2007 00:13
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: String question
what does the 1 and the +1 mean? What if I wanted to chop off more
words of the string? What would I change?
----- Original Message -----
From: Huskins, Wayne <mailto:Wayne.Huskins@xxxxxxxxxxxxx>
To: jawsscripts@xxxxxxxxxxxxx
Sent: Tuesday, November 20, 2007 7:42 AM
Subject: [jawsscripts] Re: String question
Try
Script test ()
var
string line
let line = getline()
let line = stringChopLeft (line, StringLength (StringSegment
(line, " ",
1))+1)
let line = stringChopLeft (line, StringLength (StringSegment
(line, " ",
1))+1)
saystring(line)
EndScript
W
-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx]
Sent: November 20, 2007 02:09
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] String question
OK,
I have an app. that I want to modify the say next and say prior
line pc
cursor scripts. For example, if I am going to the next line, I
want
Jaws to read the whole line minus the first two words. is there
a way
to get a line then chop off the first two words and then have
jaws speak
the rest of the line?
I was able to do it with chopping characters, but not with
words. My
function is below.
Void Function SayToEndOfLine ()
var
string Line,
STRING PartLine
LET Line = GetLine ()
Pause ()
;SayString ("Fired")
LET PartLine = StringChopLeft (Line, 6)
Pause ()
SayString (PartLine)
EndFunction
How can I do words instead of characters?
THANKS!
Gian Carlo Pedulla
GianniP46@xxxxxxxxxxxxx
LETS! GO! METS!
__________
View the list's information and change your settings at
http://www.freelists.org/list/jawsscripts
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.16.3/1144 - Release Date:
11/21/2007 4:28 PM
__________
View the list's information and change your settings at
http://www.freelists.org/list/jawsscripts
Other related posts: