[jawsscripts] Re: ScheduleFunction

  • From: "Geoff Chapman" <gch@xxxxxxxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Mon, 2 Mar 2009 03:57:22 +1100

yes. I totally concur with chad.

Since Paul Magill and the snowman introduced me to ScheduleFunction, I've
personally found it to be of infinite use in my scripting of an app in a
terminal emulator environment.
And I haven't even gotten to grips with what I can dimly see would be more
expansive use of it, by utilizing the
unscheduleFunction  aspect of it either!  I just use it, as Chad so
helpfully points out below, when, say, you want time for the screen to
settle down, before the actual function takes place.
like say if I want something to happen from NewTextEvent, upon a certain bit
of text being written to the screen, like speaking that text, or in my case,
running a function that checks for screen location to help see if it's the
screen I think it is, then say or do other appropriate stuff related to that
screen,
and if I feel that text is gunna be unique enough in occurrance to make this
worth doing.
But as heaps of text might be being written to the screen very quickly, this
NewTextEvent might fire couple hundred times in the space of a second or so,
as screen is being updated.
So scheduling whatever particular Further Condition checking type function I
might want to happen upon such text being detected anywhere in NewTextEvent,
using something like, say:

if StringContains (buffer, "Case sensitive string to watch for") then
ScheduleFunction
("FunctionToMaybeCheckAnyOtherConditionsOrJustSpeakDataOrWhatever", 3)
EndIf

seems to very usefully facilitate the non-repeated carrying out of that
function, until the last firing of the ScheduleFunction call from
NewTextEvent.


The way I Kinda understand it, anyone please correct me if I have got this
muddled, but for newby dudes this might be helpfull,
is, the last parameter of a scheduleFunction works kinda like a countDown
timer.  So, if that function that you place inside the ScheduleFunction
call, in quotation marks be aware,
is fired multiple times very quickly, the timer keeps being reset to wait
however many 100 milliseconds the last parameter of the scheduleFunction
dictates.  So it never actually gets to carry out it's stuff, until it has
the chance to count down 300 milliseconds worth of time, which can only
happen if it isn't reFired within a 300 millisecond time period.

hmmm, for the musically inclined, I've just thought of it as being a bit
like an analogy with a monophonic synth or sampler.  The ones we heard so
much of in the 80's in wrap tunes. where a vocal phrase or whatever, would
be fed into a monophonic sampler, and assigned to a certain key, such that
when that key was pressed, if left alone you'd hear the fulll complement of
the sample with it's decay etc. but if re-pressed quickly before that
happened, it'd
effectively cut off the normal proper decay/full playback of the sampled
phrase, and would only allow it to fully playback totally if the key wasn't
repressed during the length of the sample.
Thus allowing the first snippets of that sample to be used in a kind of
rhythmic funky anticipatory fashion.

with a bit of diddling, You can even get a scheduleFunction to run within
say, an onFocus frame!
because the RunScript events in frames though can't take any parameters,
you've gotta do a kinda tricky deal to get your head around initially, which
is where you place the function you want scheduled, in a ScheduleFunction
call, but then place that whole ScheduleFunction call, in another Function,
which can then of course have no parameters. like this:

Function MyFunkyFunctionToSchedule  ()
; place your main stuff you want to happen in here.
EndFunction

; now place the actual ScheduleFunction call of this function inside another
function, as it's one single line.
I also personally like to name the function indicating it's scheduling
something by placeing some kind of reference to this fact in that function's
name, though this might confuse people reading if this is new to you.

Void function ScheduleMyFunkyFunctionToSchedule ()
; now the actual scheduling of the function:
Schedule ("MyFunkyFunctionToSchedule", 3)
EndFunction

then, since this last function has no parameters,
you can use this container-like  function, if you like to call it that, in a
RunScriptEvent from a frame.

hth.

From: "Chad Foster" <chad.foster@xxxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Thursday, February 26, 2009 2:05 PM
Subject: [jawsscripts] Re: ScheduleFunction


> ScheduleFunction is better than delays or pauses since it allows the
> script or function to finish, and then fires the function or script
> after things settle down. I like it when timing is off.
>
>
> HTH,
>
> On 2/25/09, Dean Masters <dwmasters@xxxxxxxxxxxxx> wrote:
> > How is the ScheduleFunction used? If it is only to let a function be run
> > after a certain time why not just put a delay then the function?
> >
> > The following is to read a screen of text then go to the next screen and
> > continue reding until the end of the text or until a key is pressed. It
will
> > read but then skip a page or two before reading again. someone suggested
the
> > ScheduleFunctionn might help here. Any suggestions how?
> >
> > Void Function TopOfText ()
> >
> > VAR
> >
> > String CurrentLine,
> >
> > string LastLine,
> >
> > Int iKeyWasPressed ;use this to terminate the while loop.
> >
> > JAWSCursor ()
> >
> > Let LastLine = GetLine (); saves first line
> >
> > SayLine ();speaks first line
> >
> > JAWSHome ()
> >
> > NextLine ();scrols to next line
> >
> > Pause ()
> >
> > Let CurrentLine = GetLine ();saves new line
> >
> > While (CurrentLine != LastLine && iKeyWasPressed ==0);speak if two
> > adjacentlines are dissimilar or if a key was pressed
> >
> > Let iKeyWasPressed = IsKeyWaiting () ; set variable to true if a key was
> > pressed.
> >
> > If iKeyWasPressed then
> >
> > Return
> >
> > Else
> >
> > SayLine ()
> >
> > Let LastLine = CurrentLine; sets up for new comparison
> >
> > JAWSHome ()
> >
> > NextLine ();scrolls down one line
> >
> > Let CurrentLine = GetLine (); saves the new line
> >
> > EndIf
> >
> > EndWhile;loop until the two lines are the same
> >
> > If iKeyWasPressed then
> >
> > Return
> >
> > Else
> >
> > PCCursor ()
> >
> > TypeKey ("spacebar");new keystroke in Libronix 3c to go to next screen
> >
> > ; Pause ()
> >
> > Delay (3, false)
> >
> > Say ("next page", ot_status, false); for testing purposes
> >
> > JAWSCursor ()
> >
> > If FindString (GetFocus (), CurrentLine, s_bottom, s_restricted) then
> >
> > JAWSCursor ()
> >
> > NextLine ()
> >
> > Else
> >
> > JAWSPageUp ()
> >
> > JAWSHome ()
> >
> > EndIf
> >
> > EndIf
> >
> > EndFunction
> >
> > Script ReadContinuously ()
> >
> > VAR
> >
> > string CurrentPage,
> >
> > string LastPage,
> >
> > string sScheme,
> >
> > string sScheme1,
> >
> > string sScheme2
> >
> > Let sScheme = GetCurrentSchemeName ();scheme set for sounds which is to
be
> > turned off for this script
> >
> > If GetCurrentSchemeName () != "LDLS" then
> >
> > Let sScheme1 = sScheme
> >
> > Let sScheme2 = sScheme
> >
> > Else
> >
> > Let sScheme1 = "Classic"
> >
> > Let sScheme2 = "LDLS"
> >
> > EndIf
> >
> > Let g_ChapterAndVerseToggle = 0;mutes speaking of the chapter and verse
> >
> > SwitchToScheme (sScheme1);switches to the classic scheme if in LDLS
scheme
> >
> > PCToText ();function I wrote to make sure the PC and JAWS cursors start
out
> > in the text area
> >
> > JAWSCursor ()
> >
> > RefreshWindow (GetCurrentWindow ())
> >
> > Pause ()
> >
> > Let LastPage = GetWindowText (GetFocus (), false);saves Current page
> >
> > TopOfText ();speaks screen of text then scrolls to the next page
> >
> > Let CurrentPage = GetWindowText (GetFocus (), false);saves new page
> >
> > While (CurrentPage != LastPage) ;speak if two concurrent pages are
> > dissimilar
> >
> > Let LastPage = CurrentPage;sets up comparison
> >
> > TopOfText ()
> >
> > Pause ()
> >
> > Let CurrentPage = GetWindowText (GetFocus (), false);saves new page
> >
> > EndWhile;loop until the two pages are the same
> >
> > Say ("That's all folks!", ot_status, false);for testing purposes
> >
> > SwitchToScheme (sScheme2) ;Switches back from classic to LDLS scheme
> >
> > Let g_ChapterAndVerseToggle = 1;turns on speaking of chapter and verse
> >
> > EndScript
> >
> >
> > Thanks,
> > Dean
> >
> >
> > __________
> > 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
> >
> >
>
>
> -- 
> Chad Foster
> Access Technology Solutions
> Leveling The Playing Field Through Technology
> http://www.GO-ATS.net
> __________
> 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
>

__________ 
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: