In the first scenario, I have a script containing all of my handlers and snippets. The filename for this script is “Jimz_Handlerz.scpt” and it is located here… /Users/Smokestack/Library/Script Libraries
Calling the handler from a new AppleScript file requires me to declare my script library (line 1) and then I can call the handler at anytime I want with the second line. Like this:
use myHandlerz : script "Jimz_Handlerz.scpt" myHandlerz's get_fileExtensions()
In this next scenario, I am using the “load script” command to load the exact same file as the first example but this file is located on the desktop
property jimzHandlerz : load script ¬ (alias "Macintosh HD:Users:Smokestack:Desktop:Jimz_Handlerz.scpt") jimzHandlerz's get_fileExtensions()
This is the actual handler containing the command I am calling from both different scenarios..
on get_fileExtensions() tell application "Finder" set theDownloadsfolder to (path to downloads folder) set theFiles to the name extension of every file of theDownloadsfolder end tell AST copy list theFiles without keeping duplicates -- Needs AppleScript Toolbox 2_0_8.osax Scripting Addition in /Users/"Name"/Library/ScriptingAdditions end get_fileExtensions
So I guess my question is, are there situations I would rather use scenario one and other situations where scenario two would be better?
Here is a cool little tidbit of information: Using the scenario of calling handlers from a script library script or script bundle file as in the first example of my original question.. If the current script, that we are calling on an external script from a library, is a script bundle and we include a folder inside the “Resources” folder called “Script Libraries” containing the script or script bundle we are calling our external handlers from, if the file in the system “Script Libraries” folder cannot be found, then this script will not throw an error because it searches the resources folder also for script libraries.