• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Load Script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Load Script


  • Subject: Re: Load Script
  • From: Luther Fuller <email@hidden>
  • Date: Fri, 27 May 2011 17:13:10 -0500

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.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Load Script
      • From: Axel Luttgens <email@hidden>
References: 
 >Load Script (From: Luther Fuller <email@hidden>)
 >Re: Load Script (From: Stan Cleveland <email@hidden>)
 >Re: Load Script (From: Luther Fuller <email@hidden>)
 >Re: Load Script (From: Alex Zavatone <email@hidden>)
 >Re: Load Script (From: Luther Fuller <email@hidden>)
 >Re: Load Script (From: Ron Hunsinger <email@hidden>)
 >Re: Load Script (From: Luther Fuller <email@hidden>)
 >Re: Load Script (From: Axel Luttgens <email@hidden>)
 >Re: Load Script (From: Luther Fuller <email@hidden>)
 >Re: Load Script (From: Axel Luttgens <email@hidden>)

  • Prev by Date: Re: tell app, name in string var
  • Next by Date: Re: tell app, name in string var
  • Previous by thread: Re: Load Script
  • Next by thread: Re: Load Script
  • Index(es):
    • Date
    • Thread