[jawsscripts] Fw: Running a script based upon a string

  • From: "Paul Magill" <magills@xxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Tue, 31 Jan 2012 22:20:25 +1100

- from a we while ago...

Regards,
Paul from Australia

----- Original Message ----- 
From: "Doug Lee" <doug@xxxxxxxxxxxx>
Sent: Friday, August 01, 2003 2:09 PM
Subject: Re: PerformScript statement and variable translation...


I started a detailed reply to this on the day I saw your first message
about this, Dan, but I didn't get it done before I left work, and then
I forgot about it.  Spurred by the "bump" you just sent out, I have
now managed to locate the unsent message, which I will include
here now...

---Begin Original Message---

I haven't said a lot about this, partly because half of it is totally
undocumented and subject to change I suppose, and partly because the
other half is subject to a serious issue.  All herein explained...

First, you want a way to execute a script whose name is in a string
variable.  I'll start by dealing with functions, not scripts, because
this is possible for functions without using anything undocumented.

I know of three JAWS scripting functions off the top of my head that
can execute a function whose name is in a variable, and one is
indirect:  ScheduleFunction, UserBufferAddText (the indirect one), and
FormatStringWithEmbeddedFunctions.  Of these, ScheduleFunction doesn't
do it immediately and does not allow parameters or the collection of a
return value, and UserBufferAddText requires user intervention, though
it does allow parameters and even, I believe, the calling of a script
by putting the word "script" in front of the script name.  The third
function, FormatStringWithEmbeddedFunctions, is the only facility I've
found in JAWS to allow what you want:  You can use it to call a
function, even with parameters, and collect the return value.  Example
code fragment:

let sFunc = "SayString(\"Hello to all who want to know the way to make this
function go!\")"
; Note the backslashes before the nested quotes in the above line.
let sRetVal = FormatStringWithEmbeddedFunctions( "<" +sFunc +">" )
sayString("The called function returned " +sRetVal)

Null or nonexistent return values become the string "0" in sRetVal,
btw...so the above code should say, assuming I made no typos:

Hello to all who want to know the way to make this function go!
The called function returned 0

Now for the undocumented part:  To call a script, put a dollar sign
("$") in front of the name:

FormatStringWithEmbeddedFunctions("<$SayNextLine>")

will move to and say the next line.

Finally, the major issue:  Avoid at all cost calling a function this
way that might return a string longer than about 512 characters.
Doing that can crash JAWS in some cases hard enough to require a
restart of Windows before it can be used again.  I reported this to FS
a ways back, but as I've never seen anyone use the
FormatStringWithEmbeddedFunctions function, I wouldn't at all blame
them for not reacting quickly to that particular report.


__________�

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

Other related posts:

  • » [jawsscripts] Fw: Running a script based upon a string - Paul Magill