Re: Scripter (The Program)
Re: Scripter (The Program)
- Subject: Re: Scripter (The Program)
- From: Mark Alldritt <email@hidden>
- Date: Thu, 09 Nov 2000 11:03:12 -0800
on 9/11/2000 10:28 AM, email@hidden at
email@hidden wrote:
>
> on run
>
> set my TestHandler to run script "TestHandler
>
> on TestHandler(theName)
>
> display dialog \"Hello, \" & theName
>
> end"
>
> TestHandler("R23")
>
> end run
>
>
>
> on TestHandler()
>
> end TestHandler
>
>
This does not compile with Scripter 2.5, giving the
>
wrong-number-of-parameters error on TestHandler("R23") in the 6th line. And
>
it shouldn't compile; the error report is correct. The handler TestHandler()
>
is defined at the bottom as having no parameter (there is nothing between
>
the parentheses), yet you called it with a parameter, "R23". If you remove
>
the first statement (the long Run Script command) and try to compile what's
>
left, you get the same error, as you clearly should.
>
>
If you try the shorter version (without the Run Script statement) in Script
>
Editor, it will compile, but it will generate a runtime error when you run
>
it, complaining that R23 doesn't match the parameter list required by
>
TestHandler().
>
>
Scripter implements stricter syntax checking than other editors, and this is
>
a case where that facility comes into play. It is surely more useful to
>
discover this syntax error at compile time than at run time.
>
>
If you comment out the illegal statement, TestHandler("R23"), Scripter will
>
compile and run your script, returning a handler object from the Run Script
>
command, just as Script Editor does.
>
>
What misled you is the fact that Script Editor will compile and run the full
>
script. You misinterpreted the meaning of this when you concluded that it
>
proves your script to be correct. In fact, it demonstrates that Script
>
Editor has a problem. Script Editor executes the Run Script command
>
correctly but then fails to catch the parameter error in the last statement
>
-- even though it does catch the parameter error when the Run Script
>
statement is omitted.
>
>
What is happening is that Script Editor doesn't even call the last statement
>
in the full version of the script. You can confirm this by adding a command
>
to the TestHandler() handler, like Beep. Then run the script. It never
>
beeps, because TestHandler() is never called -- and therefore no runtime
>
error is generated. There's something wrong with Script Editor, here. Or
>
maybe it's a problem with the Run Script osax command, which I guess is
>
known to have problems.
I should probably not be involved in this discussion, but since you used the
term "other script editors", I feel compelled to point out that Scripter's
extended syntax checking is in error.
Try the following snippet:
on TestHandler(p1)
display dialog p1 buttons "OK" default button 1
end TestHandler
on TestHandler2()
beep
end TestHandler2
set TestHandler to TestHandler2
TestHandler()
This is perfectly legal (though perhaps not desirable) AppleScript that
compiles and runs in the Script Editor. The Scripter Demo complains about
an incorrect number of parameters.
Cheers
-Mark
---------------------------------------------------------------------
Mark Alldritt Late Night Software Ltd.
Phone: 250-380-1725 333 Moss Street
FAX: 250-383-3204 Victoria, B.C.
WEB:
http://www.latenightsw.com/ CANADA V8V-4M9