On May 27, 2011, at 4:40 PM, Axel Luttgens wrote: After all, it doesn't make very much sense for a script supposed to be a standalone entity liable to be called from everywhere to depend on characteristics of the caller.
Moreover, I'm not sure that the notion of parent (and, more generally, of inheritance in AppleScript sense) is relevant in this precise context.
I should explain the nature of my project. The previous version consisted of 6 applications, all of which are used to do tasks related to disk image files. These applications are named: New, Convert, Burn, Inspect, Preferences and SetBGpict and are located in a folder in the Dock. There is a lot of duplicate code in these applications.
The idea is to rewrite all of these applications as runnable .scpt files and put all the common code in the main application code. The main application bundle contains the folders: MenuItemAppls and MenuItemScripts in its Resources folder.
The MenuItemScripts folder contains the 6 .scpt files.
The MenuItemAppls folder contains application bundles, each with a distinctive icon, with the same names as the 6 .scpt files. The script of each of these applications looks like this ...
-- this application located in /Application/Contents/Resources/MenuItemAppls/ on run tell application "Finder" to set hostAppl to (container of container of container of container of (path to me)) as text launch application hostAppl tell application hostAppl to entryPointHandler() end run -----------------------------
And the entry point handlers, one for each .scpt file, all look like ...
on entryPointHandler() try (((path to me) as text) & "Contents:Resources:MenuItemScripts:NameOfSome.scpt") as alias run (load script the result) on error errText number errNr if errNr = -128 then return else if errNr = -2700 then my showInstruction(errText) else my showError(errText, errNr) end if end try end inspectMenuItem ----------------------------------------------------------
The main application creates a folder in the user's Application Support folder, writes an alias file into this folder for each item in the MenuItemAppls folder, then installs this folder into the Dock.
Now I have a menu in the Dock allowing me to do most anything I need to do with disk image files. And it's already working quite well.
|