Re: Scripter (The Program)
Re: Scripter (The Program)
- Subject: Re: Scripter (The Program)
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 09 Nov 2000 22:15:26 -0500
on 11/9/00 2:03 PM, Mark Alldritt at email@hidden wrote:
>
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.
I am always tempted to defer to anything you say about what is legal in
AppleScript, Mark, because you know far more about the innards of
AppleScript than I. But....
What it boils down to is whether AppleScript is supposed to tolerate the use
of an identifier as a variable name when it is spelled the same as an
identifier labeling a handler within the same scope.
The AppleScript Language Guide, p. 27 (in my 1993 edition), says that a
variable name and a handler name are both identifiers: "variable names are
identifiers.... Identifiers are also used as labels for ... handlers." In
your script, the identifier "TestHandler" is used both as a variable and as
a label for the handler TestHandler(). Surely this is illegal in
AppleScript. Nothing I have seen in the documentation allows overloading of
identifiers in this fashion.
Your script works in both products if the variable name is changed to
something different from the handler name -- for example:
Set X to TestHandler2
X()
The fact that your script works in Script Editor does not convince me that
it is legal. I showed, for example, that Script Editor behaves illegally
when running Richard23's script. It seems to me that Scripter is correctly
flagging a syntax error in your script.
What is your touchstone for legality?
Where is Chris Nebel when we need him?:
-
Bill Cheeseman, Quechee, Vermont <
mailto:email@hidden>
The AppleScript Sourcebook
<
http://www.AppleScriptSourcebook.com/>
Vermont Recipes-A Cocoa Cookbook
<
http://www.stepwise.com/Articles/VermontRecipes/>