TclAppleScript Extension Command

NAME

AppleScript - Communicate with the AppleScript OSA component to run AppleScripts from Tcl.

SYNOPSIS

AppleScript execute ?flags value? scriptData1 ?scriptData2 ...?
AppleScript run ?flag value? scriptName

DESCRIPTION

This command is used to execute AppleScript code from Tcl. You can run compiled scripts, and execute script data in-line. It has the general form

AppleScript option ?arg arg ...?

The possible sub-commands are:
AppleScript execute scriptData
This compiles and runs the script in scriptData (concatenating first) in-line, and returns the results of the script execution.
AppleScript run scriptName
This runs an external AppleScript file, scriptName. If the script runs successfully, the command returns the return value for this command, coerced to a text string. If there is an error in the script execution, then it returns the error result from the scripting component.

Notes:

The AppleScript command dates back to the days of the Classic MacOS, and was originally designed as a stopgap command to fill the place of "exec" on the old Classic MacOS. Much of its original code and commands are now obsolete, and its public API has been updated to support a simpler purpose, to allow execution of AppleScript code either in-line in a Tcl script, or from an external AppleScript file.

Examples:

Executing a script in-line:

AppleScript execute {

tell app "Finder"

get name of every disk

end tell

}

Running an external script file:

Save the above code to a file called "Test.applescript" (from any text editor) or "Test.scpt" (from Apple's Script Editor tool) and execute as follows:

AppleScript run "Test.applescript"

Download

SourceForge Project Page