• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: how can script bundles store extra stuff?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how can script bundles store extra stuff?


  • Subject: Re: how can script bundles store extra stuff?
  • From: Daniel Jalkut <email@hidden>
  • Date: Sat, 23 Jul 2005 18:16:44 -0400


On Jul 23, 2005, at 4:02 PM, Matt Neuburg wrote:

(1) The dictionary entry for "path to resource" is lying. It claims

explicitly that by default it will look in the script bundle, but that's not

true. In the case of a script bundle, you must supply explicitly the

pathname of that script bundle.


I dragged a file, "Furl.scpt" to the "Bundle Contents" drawer in Script Editor, and saved as a script bundle. This is working for me, if I run it from either FastScripts or ASM:

display dialog (path to resource "Furl.scpt") as string

If you get any kind of error in a script run from Script Editor, the behavior is to silently fail. If you try to the same thing from FastScripts you should get an error dialog, at least.

(2) "path to me" will get you the pathname of the script bundle, but not if

you're running from within Script Editor. (I regard this as either a bug in

Script Editor or darned silly.) You have to use a script runner such as the

Script Menu. Even then you can't be sure. Some script runners do the right

thing; others don't. Entourage doesn't even see the script (no big

surprise). iTunes sees it, but thinks it is called "main.scpt" no matter

what the script bundle is called, and "path to me" gets iTunes's pathname,

not the script's. BBEdit does exactly the right thing.


Supporting scripts saved as script bundles did require developers to explicitly change their code, I expect Entourage probably shows them as a directory?  

As far as the "path to" behavior, it's not surprising that so many apps have historically gotten it "wrong," because Apple has made it difficult to get it right. Supposedly this is fixed in 10.4, but if that's true then Script Editor for instance must go out of its way to continue getting it wrong.

To get the expected behavior for "path to me" in FastScripts (prior to 10.4), I had to patch out the "path to me" (ears/ffdr) event handler, and explicitly return the script's path instead of the application's. Furthermore, the host app has to observe and perform the requested coercion (as far as I can tell, the system will never do it for me), or else the user gets failures if they happen to ask, for example, for "path to me as text." Worst of all, the only way I figured out how to do all this was by pleading for help and getting a response from a "smart AppleScript dude" (thanks, Andy Bachorski!) on a mailing list.  There's no FAQ for this issue :)

In the end, I was left with the distinct feeling that few apps would go through all the hoops required to make it work as one would intuitively expect it to.  I haven't tried removing my workaround on 10.4 to see if the built-in path to me handler now works as expected.

Daniel

 _______________________________________________
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

  • Follow-Ups:
    • Re: how can script bundles store extra stuff?
      • From: Paul Berkowitz <email@hidden>
References: 
 >Re: how can script bundles store extra stuff? (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: file format backwards compatibility question
  • Next by Date: Re: how can script bundles store extra stuff?
  • Previous by thread: Re: how can script bundles store extra stuff?
  • Next by thread: Re: how can script bundles store extra stuff?
  • Index(es):
    • Date
    • Thread