Re: how can script bundles store extra stuff?
Re: how can script bundles store extra stuff?
- Subject: Re: how can script bundles store extra stuff?
- From: has <email@hidden>
- Date: Sun, 24 Jul 2005 19:27:21 +0100
Daniel Jalkut wrote:
>>'path to me' is a synonym for 'path to current application'. It's really a bug - 'path to me' is both meaningless and misleading - but Apple are unlikely to change the current behaviour as it'd break lots of existing code.
>
>They fixed it in 10.4. [...] You'll find within it this text:
>
>"The path to me command now returns the correct result for compiled scripts, including those that are run using the run script command."
Hmmm, must've missed that. Thanks for the heads-up. Annoyingly vague, and once I get back to working on my Python OSA component I'll need to harrangue the relevant parties for more precise information. But for now I'm guessing that the OSA and/or AppleScript component have been tweaked so that scripts loaded via OSALoadFile() now retain path information, with extra hooks catching the 'path to me' event before it's dispatched to the 'path to' osax and providing alternate handling. Still inadequate, mind you: Apple still need to add an OSASetScriptPath() function to the OSA to allow OSA components to optionally provide script instances created via OSALoad() and OSACompile() with a 'source file' path. But at least it's a step in the right direction.
>>And some OSA client applications provide their own ad-hoc workarounds by intercepting the 'path to current application' event and returning a path to the file from which that script was loaded; it's a total hack and semantically incorrect, but it generally gives the user the value they want.
>
>Since it appears that even Apple has embraced this hack, perhaps its semantic incorrectness is diminished?
No, applications that intercept 'path to me/current application' are still doing the wrong thing. Apple, to their credit, appear to be trying to de-hackify 'path to me', and now distinguish between 'path to me' and 'path to current application' at least on some level.
> I think if the words are "path to me" then it's quite reasonable to expect the script, because that's the only "me" the script author knows.
It's a reasonable - if not necessarily correct - assumption for end users to make. The problem is that AppleScript packs both the 'me' reference and 'current application' constant into an Apple event as null descriptors, so an application or osax handling that event is unable to determine which one the user meant. For example, in Smile, both 'path to me' and 'path to current application' return the path to the script file if one exists, or to the Smile application if not. Whereas for 'path to me' what it ought to do is return the path to the script file if one exists or raise an error if not, and for 'path to current application'. always return the path to Smile.app.
So the situation is still a mess: the OSA API still doesn't provide client applications with all the tools needed to do this stuff properly, and user scripts still can't rely on 'path to me' and 'path to current application' to return sensible results in every application. Though FWIW, there should be at least a few more applications that do the right thing now, i.e. those that only use OSALoadFile() and don't provide custom 'path to' handling. But editing tools and legacy apps that don't meet these conditions will still be out of luck.
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