Language Guide

CHAPTER 8
Handlers
Command Handlers for Script Applications 247
Files, folders, or disks are not moved, copied, or affected in any way when their
icons are dragged and dropped over a script application’s icon. The Finder just
gets a list of their identities and sends that list to the script application as the
direct parameter of the Open event. Of course, the script in the script applica-
tion could easily tell the Finder to move, copy, or otherwise manipulate them.
Note
Due to a known limitation of system software, you can’t
drop icons on an icon for a script application that’s stored
on a floppy disk.
You can also run an Open handler by sending a script application the Open
command. For details, see “Calling a Script Application” on page 251.
Handlers for Stay-Open Script Applications 8
By default, a script application that receives a Run or Open command handles
that single command and then quits. This allows it to perform a single task and
get out of your way. In contrast, a stay-open script application (one saved with
the Stay Open checkbox selected in the Script Editor’s Save As dialog box)
stays open after it’s launched.
A stay-open script application can be used for any of these purposes:
If you run a script frequently, it runs faster as a stay-open application than it
does if it has to be launched each time.
Stay-open script applications can receive and handle other commands in
addition to Run and Open. This allows you to use a script application as a
script server that, when its running, provides a collection of handlers that
can be invoked by any other script.
Stay-open script applications can perform periodic actions, even in the
background, as long as the script application is running.
All stay-open applications receive periodic Idle events. If a stay-open script
application includes a handler for the Idle event, it can perform periodic
actions whenever it is not responding to other events. If a stay-open script
application includes a handler for the Quit event, it can perform some action,
such as checking with the user, before quitting.