Re: Inheritance and Loaded Libraries (solved)
Re: Inheritance and Loaded Libraries (solved)
- Subject: Re: Inheritance and Loaded Libraries (solved)
- From: has <email@hidden>
- Date: Wed, 3 Nov 2004 18:05:09 +0000
I wrote:
Point is you can't send AppleScript references via Apple events;
they don't support it.
Must correct myself here after rechecking with the AE debugger:
actually you can. They're encoded as object specifiers, though of a
kind that's unique to AppleScript - formUserPropertyID (declared in
AERegistry.h) - and which isn't documented publically as far as I can
tell.
(Don't know what the heck I was doing wrong to miss this earlier, but
live and learn...:p)
Anyway, this means you can get or set script properties anywhere
within an applet using standard get and set events. AppleScript packs
the full reference using its custom object specifiers, sticks the
result into a get/set event's direct parameter and sends this event
to the applet. The applet runtime (which is obviously a bit smarter
than I previously thought) processes the received event using the
appropriate OSA calls to locate the relevant script property and
get/set its value (see the 'miscellaneous commands' section of the
OSA API reference for more info on the calls involved). This all
seems to work without problem.
--
OK, now for the bad:
Q1. Why does the following fail:
c() of b of a of application "ScriptServer"
This is easy to answer now I'm holding the AE debugger the right way
up.:p AppleScript is forgetting to specify the target object (b of a)
when constructing the outgoing Apple event, so is effectively telling
the applet to do:
c() of application "ScriptServer"
Given the lack of documentation in this area, it's hard to say if
this is a bug, a half-finished abandoned feature or a hole in the
language spec. Feel free to file a bug report and see if anything
comes of it; I guess that's one practical way to find out. :)
--
Q2. Why does the following partially work:
tell b of a of application "ScriptServer" to c()
This time AppleScript does remember to specify the target script,
storing the reference as one of the Apple event's attributes
(keySubjectAttr). The applet obviously knows to look for this
attribute when processing the event and use the relevant OSA calls to
find that script object. It then gets handler c from that script and
executes it. The problem this time is that the applet is executing
the handler in the wrong context: it should be using the script
object it got the handler from but instead it uses the applet's
top-level script. Again, no idea if this is an accidental bug or
deliberately abandoned feature, though the fact that both AppleScript
and the applet know about and use the keySubjectAttr event attribute
suggests that what's going on isn't completely accidental.
--
To summarise:
1. There's breakage in the AppleScript component.
2. There's breakage in the applet shell.
3. I need to pay more attention when using AEDebug to avoid
prematurely reaching the wrong conclusions. :p
I've no idea if the first two problems are accidental (in which case
file a bug and hopefully they'll be fixed eventually) or deliberate
(i.e. written off, so fuggedaboutit), though I'm pretty sure they've
been broken for years, if not forever. Either way, use completely at
your own risk and don't be surprised should things suddenly go [even
more] wrong. I certainly wouldn't recommend their use, especially not
when there are much more reliable and properly documented ways to
build module-based systems.
The third is just sloppiness on my part; but hey, you gets what you
pays for. Besides, this is relatively deep, poorly-documented and
little-used OSA arcana that not many folk understand, so I think I'm
doing quite well getting to the bottom of it at all. Even if it did
take a couple of attempts to get there. ;)
Regards,
has
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden