image

Why Do Applications Open Spontaneously?

image

Why do applications open spontaneously? The trouble is that certain applications must be running in order to provide a dictionary. So every time AppleScript needs the dictionary of such an application — not just in order for a script editor to display a dictionary, but in order to compile or decompile a script that targets that application — the application must start up if it isn’t running. So this is a problem with the system, and with how AppleScript works. It has nothing to do with Script Debugger. In fact, Script Debugger does two things to reduce this behavior.

NOTE: To compile a script, you must let AppleScript launch any needed applications. Compilation is something that AppleScript does, not something that Script Debugger does; so Script Debugger can’t prevent this behavior.

Opening and Decompiling a Script

When you open a script that targets an application which must be launched in order for AppleScript to decompile it, Script Debugger detects this and optionally (if the corresponding General preference is checked) presents a dialog:

image

You can proceed to open the script (and allow the application to launch) if you wish, but perhaps the overhead of launching an application just to read a script seems unwarranted. If this script was saved with Script Debugger, it contains a text version, and you can click Open As Text to open that instead. Thus you can read the script without launching the targeted application.

If the script does not contain a text version, the Open As Text button won’t appear; your only choices will be to open the script and let AppleScript launch BBEdit, or to cancel and not open the script at all.

Opening a Dictionary

Script Debugger makes heavy use of an application’s dictionary. For example, in order to calculate the tell context, Script Debugger must load the target application’s dictionary. This could cause the target application to launch if it is not running. And Script Debugger needs the tell context when you start to open the File menu (because of the Open XXX’s Dictionary menu item), so there may be a delay as you choose from the File menu, while the target application launches. And then, of course, there’s the whole business of what happens when you search the dictionaries of multiple applications simultaneously.

The good news, however, is that this should happen only once for each application. Script Debugger caches an application’s dictionary (in ~/Library/Caches/Script Debugger) when it opens the dictionary, provided you have not unchecked “Cache generated dictionaries” in the Dictionary preferences. So, as long as the application’s dictionary and location don’t change, Script Debugger won’t have to launch that application again in order to access its dictionary.

Note that this has nothing to do with the discussion under “Opening and Decompiling a Script” earlier on this page. Even when Script Debugger has cached (say) BBEdit’s dictionary, AppleScript has not, so when you open a script that targets BBEdit, AppleScript will still try to launch BBEdit if it isn’t running.

However, you can uncheck “Cache generated dictionaries”, or clear the cache on demand by clicking the Clear Cache button, and there are certain specialized circumstances where you might wish to do this. In particular, some applications with 'aete' dictionaries allow those dictionaries to be extended through plug-ins (notable examples are QuarkXPress and InDesign). Script Debugger has no way to notice when you add or remove a plug-in, so the dictionary that it displays, coming from the cached copy, will be out of date.

Applications that do not use this plug-in architecture do not present any difficulties, and are irrelevant here. If you install a new version of an application, Script Debugger will notice that the dictionary has changed and will automatically refresh the cached copy.

So, if you use these applications, it is up to you to remember to remove the cached copy of the dictionary each time you alter the application by adding or removing plug-ins. There are three ways, or levels, for doing this:



image
What’s The Big Deal With Line Endings? Hey, Script Debugger Changed My Formatting!
image