Script library question

My question today is a bit hard to explain…

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)’?

I don’t think so. You only have path to me and path to current application to work with.

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.

@alldritt
I was hoping I could avoid modifying hundreds of scripts, but I was pretty sure of the answer…

@tree_frog
This is more or less the procedure I use. The difference is that all my libraries are associated with an Applescript dictionary (sdef).