Class

NSScriptCommand

A self-contained scripting statement.

Declaration

@interface NSScriptCommand : NSObject

Overview

An instance of NSScriptCommand represents a scripting statement, such as set word 5 of the front document to word 1 of the second document, and contains the information needed to perform the operation specified by the statement.

When an Apple event reaches a Cocoa application, Cocoa’s built-in scripting support transforms it into a script command (that is, an instance of NSScriptCommand or one of the subclasses provided by Cocoa scripting or by your application) and executes the command in the context of the application. Executing a command means either invoking the selector associated with the command on the object or objects designated to receive the command, or having the command perform its default implementation method (performDefaultImplementation).

Your application most likely calls methods of NSScriptCommand to extract the command arguments. You do this either in the performDefaultImplementation method of a command subclass you have created, or in an object method designated as the selector to handle a particular command.

As part of Cocoa’s standard scripting implementation, NSScriptCommand and its subclasses can handle the default command set for AppleScript's Standard suite for most applications without any subclassing. The Standard suite includes commands such as copy, count, create, delete, exists, and move, as well as common object classes such as application, document, and window.

For more information on working with script commands, see Script Commands in Cocoa Scripting Guide.

Topics

Initializing a script command

- initWithCommandDescription:

Returns an a script command object initialized from the passed command description.

Getting the current command

+ currentCommand

If a command is being executed in the current thread by Cocoa scripting's built-in Apple event handling, return the command.

Getting the Apple event

appleEvent

If the receiver was constructed by Cocoa scripting's built-in Apple event handling, returns the Apple event descriptor from which it was constructed.

Executing the command

- executeCommand

Executes the command if it is valid and returns the result, if any.

- performDefaultImplementation

Overridden by subclasses to provide a default implementation for the command represented by the receiver.

Accessing receivers

evaluatedReceivers

Returns the object or objects to which the command is to be sent (called both the “receivers” or “targets” of script commands).

receiversSpecifier

Sets the object specifier to receiversSpec that, when evaluated, indicates the receiver or receivers of the command.

Accessing arguments

arguments

Sets the arguments of the command to args.

evaluatedArguments

Returns a dictionary containing the arguments of the command, evaluated from object specifiers to objects if necessary. The keys in the dictionary are the argument names.

Accessing the direct parameter

directParameter

Sets the object that corresponds to the direct parameter of the Apple event from which the receiver derives.

Getting command information

commandDescription

Returns the command description for the command.

- isWellFormed

Returns a Boolean value indicating whether the receiver is well formed according to its command description.

Handling script execution errors

scriptErrorExpectedTypeDescriptor

Sets a descriptor for the expected type that will be put in the reply Apple event if the sender requested a reply, execution of the receiver completes, and an error number was set.

scriptErrorNumber

Sets a script error number that is associated with the execution of the command and is returned in the reply Apple event, if a reply was requested by the sender.

scriptErrorOffendingObjectDescriptor

Sets a descriptor for an object that will be put in the reply Apple event if the sender requested a reply, execution of the receiver completes, and an error number was set.

scriptErrorString

Sets a script error string that is associated with execution of the command.

Suspending and resuming commands

- suspendExecution

Suspends the execution of the receiver.

- resumeExecutionWithResult:

If a successful, unmatched, invocation of suspendExecution has been made, resume the execution of the command.

Constants

NSScriptCommand—General Command Execution Errors

NSScriptCommand uses the following error codes for general command execution problems:

Initializers

Instance Properties

Relationships

Inherits From

Conforms To

See Also

Script Commands

NSQuitCommand

A command that quits the specified app.

NSSetCommand

A command that sets one or more attributes or relationships to one or more values.

NSMoveCommand

A command that moves one or more scriptable objects.

NSCreateCommand

A command that creates a scriptable object.

NSDeleteCommand

A command that deletes a scriptable object.

NSExistsCommand

A command that determines whether a scriptable object exists.

NSGetCommand

A command that retrieves a value or object from a scriptable object.

NSCloneCommand

A command that clones one or more scriptable objects.

NSCountCommand

A command that counts the number of objects of a specified class in the specified object container.

NSCloseCommand

A command that closes one or more scriptable objects.