Language Guide
CHAPTER 4
Commands
104 Command Definitions
AppleScript sends an implicit Run command whenever it begins to execute a
Tell statement whose target is an application that is not already open. This
can cause problems with applications such as the Scriptable Text Editor that
normally perform specific tasks on startup, such as opening a new window.
Here’s an example:
tell application "Scriptable Text Editor"
open file "Hard Disk:Status Report"
end tell
Before AppleScript opens the file Status Report, it sends an implicit Run
command to Scriptable Text Editor. If the application is not already open,
the Run command causes Scriptable Text Editor not only to launch but also
to perform its usual startup tasks, including opening an untitled window.
Therefore, running this script opens two windows: an untitled window and
a window for the file Status Report.
If you don’t want AppleScript to send an implicit Run command when it
launches an application as the result of a Tell statement, use the Launch
command explicitly at the beginning of the statement:
tell application "Scriptable Text Editor"
launch
open file "Hard Disk:Status Report"
end tell
In this case, AppleScript launches the application without sending it a Run
command, and the application opens only a window for the requested
document.
For similar reasons, it is sometimes important to use the Launch command
before sending the Run command to a script application. For more information,
see “Calling a Script Application,” which begins on page 251. For information
about Run handlers, see “Run Handlers,” which begins on page 243.
Although the target of a Launch command is always an application, it is
actually handled by the Finder. Unlike the other application commands defined
in this chapter, it doesn’t need to be explicitly supported by applications and
doesn’t appear in any application’s dictionary.