• 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: Resource folder of library script?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Resource folder of library script?


  • Subject: Re: Resource folder of library script?
  • From: Luther Fuller <email@hidden>
  • Date: Tue, 11 Feb 2014 09:51:40 -0600

On Feb 11, 2014, at 6:02 AM, Jim Brandt wrote:

Here's a script representing my library:

on ScriptA()
display dialog (path to me) as text
end ScriptA

save it as a script bundle named ScriptA and run it using a second script:

set sa to load script alias (((path to desktop) as text) & "ScriptA.app")

sa's ScriptA()

the display points to the call script's path

save ScriptA as an application and the result is the same.

What I want is the path to the ScriptA, not to the calling script. I want to store resources in the script bundle of ScriptA, and have ScriptA know how to retrieve those resources, no matter where ScriptA is stored. (using a path to resource folder in ScriptA). Instead, I'm getting the path to the resource folder of the calling script.

I am going to have to do some experimenting to see if this can be done, but I can see from your code why you are not getting what you want.

In your Main application script, you use ...

set sa to load script alias (filePath)

This copies the code from filePath into Main, then you use ...

sa's ScriptA()

which runs code that is now in Main. (Code was copied from ScriptA, but is now located in Main.)
This causes path to me to report its correct location as the path to Main.

You might want to experiment with using 'run script', instead of 'load script'. This will make the code run within its desired location.

Here is what I just tested:


-- saved as an application bundle named "scriptA.app"
on ScriptA()
set pathToMe to ((path to me) as text)
display dialog pathToMe
end ScriptA

and

-- saved as an application bundle named "Main.app"
property pathToScript : alias "OS_X:Users:lutherfuller:Desktop:test folder:scriptA.app"
on run
set appPath to (pathToScript as text)
launch application appPath
tell application appPath to ScriptA() -- or use activate or run without launch


beep
delay 1
end run


This seems to behave according to your specifications.
CAUTION: I have used launch application ... in "Main.app".
This does NOT work correctly in Mt. Lion and Mavericks.


 _______________________________________________
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

  • Follow-Ups:
    • Re: Resource folder of library script?
      • From: Luther Fuller <email@hidden>
References: 
 >Re: Resource folder of library script? (From: Jim Brandt <email@hidden>)

  • Prev by Date: Re: Why these errors?
  • Next by Date: Re: Why these errors?
  • Previous by thread: Re: Resource folder of library script?
  • Next by thread: Re: Resource folder of library script?
  • Index(es):
    • Date
    • Thread