Scope of Script Libraries

I have several script libraries with handlers to do things in specific applications (e.g., QuarkXPress_lib.scpt, Finder_lib.scpt, etc.) and a common library with generic handlers. What I need to do is create a script that loads an application-based script library and is able to globally share routines with it from the common library. I am looking to do this without passing the entire common library to the application library each time. In other words, I am looking to do this:

--Saved in Finder_lib.scpt
on do_something()
	set x to name of startup disk
	tell common_lib to return do_something_else(x)
end do_something

--Saved in Common_Lib.scpt
on do_something_else(x)
	display dialog "The value is " & (x as string)
end do_something

--Third Script
property finder_lib : load script "Finder_lib.scpt" as alias
property common_lib : load script "Common_Lib.scpt" as alias

tell finder_lib to do_something()

Now I know I could put “property common_lib : load script “Common_Lib.scpt” as alias” into Finder_lib.scpt but then I’m loading it twice. I know I could also pass it to Finder_lib.scpt by placing “common_lib” into the parameters of the do_something handler: “do_something(common_lib)” but is there a better way to load Common_Lib.scpt once and have it available to all my other script libraries?

Thanks,
Jon

What you want is inheritence, which is supported in AppleScript.

By defining a parent in your script, you gain the handlers and properties of the parent script. Multiple scripts can share the same parent, and the parent handlers are available to all.

http://developer.apple.com/techpubs/macosx/Carbon/interapplicationcomm/AppleScript/AppleScriptLangGuide/AppleScript.f5.html discusses parents, inheritence, and the associated usage and caveats.

If you are very interested in this stuff, you can visit “The Little Page of ASLoader”, which is the most complete solution for what you’re looking for, even when it is a complex project…
http://www.barple.pwp.blueyonder.co.uk/asloader/index.html

Does anyone have any current contact information for the author? (If the address on the main page worked, I wouldn’t ask.)

You can try to contact him at…

has@macscripter.net

Thanks for the tip. :slight_smile:

I am looking for more information on the design and was wondering if it was still under active development.