Re: parent properties - [it's your breath...let's talk scope]
Re: parent properties - [it's your breath...let's talk scope]
- Subject: Re: parent properties - [it's your breath...let's talk scope]
- From: Bill Cheeseman <email@hidden>
- Date: Mon, 05 Feb 2001 06:36:55 -0500
on 2/4/01 10:49 PM, Richard 23 at email@hidden wrote:
>
... it's just too complicated to use libraries and this
>
really limits the productivity of new users (as well as experienced)
>
who cannot easily benefit from the efforts of others who would gladly
>
provide such files if only a method existed.
I'm not persuaded by your arguments. Script libraries are easy to use. (But
they're hard to write -- code reusability requires a lot of foresight.)
Many of us have asserted for years that scripters should keep all of their
current libraries in a standard location. The Scripts folder is the most
obvious candidate, but the Application Support folder will do. Write your
scripts to find libraries in one of these standard places, and you're all
set. If you distribute your library and sample scripts, just make sure your
instructions tell your customers where to keep the library. Management of
obsolete versions can be done somewhere else so as not to interfere with
this simple scheme.
I wrote a handler about a year ago that finds a library quickly in any of
the obvious places with a minimum of effort.
to Hunt for itemName at specialFolders
--Returns path to itemName as string, or empty string if not found.
repeat with aFolder in specialFolders
try
return alias ((path to aFolder as string) & itemName) as string
on error number -43 --item not there, go to next folder
end try
end repeat
return "" --return empty string if item not found
end Hunt
Here's how to use the Hunt handler to find the Standard Additions osax (as
if you didn't already know where it is), for example:
Hunt for "Standard Additions" at {scripts folder, application support}
Then make the result into an alias and Load Script the result.
Add more special folders to the list if you want a broader search. It's
still very fast, and it doesn't call the Finder.
For details, see:
<
http://www.AppleScriptSourcebook.com/tips/findlibrary.html>
As to having to "tell myLib" when you want to use a loaded script library's
commands or properties, I don't think this is any harder than telling an
application to use its commands. Indeed, it can be viewed as a plus in terms
of clarity and scoping.
-
Bill Cheeseman, Quechee, Vermont <
mailto:email@hidden>
The AppleScript Sourcebook
<
http://www.AppleScriptSourcebook.com/>
Vermont Recipes-A Cocoa Cookbook
<
http://www.stepwise.com/Articles/VermontRecipes/>