RE: extending an command
RE: extending an command
- Subject: RE: extending an command
- From: has <email@hidden>
- Date: Sun, 9 Nov 2008 00:11:34 +0000
Mahesh Vyas wrote:
I am getting error while compiling a script if command (with
parameters) defined in application is also defined in library loaded
with application.
"open" command is defined in Application, same command can also be
executed with parameter
Now if library loaded dynamically also defines "open" command (with
parameter ).
If we write a script and use "open" without parameters, it compiles
and executes properly.
If use "open" as parameters then script doesnt compile and gives
error at the parameter of open.
If we do not load the library, the "open" command works fine with
parameter
and:
Error is "Expected End of line but found identifier"
Application is QuarkXpress and dynamic libraries are 2 XTensions.
one XT defines open as
"open", "Open the specified object(s)",
kCoreEventClass, kAEOpen, noReply, "", replyOptional, kReplyParams,
typeObjectSpecifier, "list of objects to open", directParamRequired,
kSingleNotEnumChanges,
{
// its parameters
}
and our XT defines open as
"open", "Open the specified object(s)",
kDispatchSuite, kAEOpen, noReply, "", replyOptional, kReplyParams,
typeObjectSpecifier, "list of objects to open", directParamRequired,
kSingleNotEnumChanges,
{
}
It sounds like you're writing one or both of these extensions
yourself. If so, note that implementation-related questions should be
posted to applescript-implementors, not applescript-users.
Anyway, having your plugin override commands that are already defined
by the host application (or, for that matter, another plugin) is -
based on my understanding of how this stuff works - a bad idea,
especially when your own command has different class/id codes and/or
parameters to the original.
Short advice: don't do it. Use unique names and AE codes for all
commands that you define yourself. If they don't collide, they can't
conflict.
Long version: the rules by which the AppleScript parser looks for
commands defined by the application dictionary, including how it deals
with overlapping definitions of the same command, are not publically
documented by Apple.
A few years back I put quite a bit of work into black-box reverse-
engineering the AS parser's operation (a right PITA in itself). If
memory serves, except for a couple of special cases (get and set
commands), AS only ever uses the first definition of a command it
finds in the application dictionary and ignores any subsequent
definitions that have the same command name. So if you define a
command with the same name but different parameters as an existing
one, only one of those definitions will actually be usable within
scripts (i.e. whichever one that parser encountered first).
(Like most things AppleScript-related, AppleScript's dictionary parser
is hoplessly under-specced and under-documented, and dreadfully over-
permissive, with the result that you've no way of knowing what you
shouldn't do unless you obviously break it.) You might, I suppose,
look for some clever loophole to let you do what you want, but my
experience of AppleScript is that the more you try to outsmart it, the
more it finds ingenious ways to kick your butt. KISS is best.
HTH
has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden