Here is a example of what I’m currently doing:
I have a command in a library that displays a window with a title in its title bar.
From the script the command was triggered, I pass a parameter ‘window title’ with the value of ‘path to me’.
The library takes this path to calculate the title and uses it to do other stuff.
Is it possible, in the library, to get the path of the ‘triggering’ script, without passing any parameter?
Something like ‘path to (parent script)’?
It’s possible for the calling script to set a property of its temporary copy of a script library, but it’s a bit of a fragile pattern.
SomeLibrary.scpt:
property window_title : missing value
to doSomethingWithWindowTitle()
display dialog window_title
end doSomethingWithWindowTitle
Calling Script:
use scripting additions
use SL : script "SomeLibrary"
set SL's window_title to POSIX path of (path to me)
SL's doSomethingWithWindowTitle() -- Displays path of calling script.
See here for the only known mention of this pattern – there are some caveats. It’s also probably safer if window_title is wrapped in a script object.