DekGenius.com
[ Team LiB ] Previous Section Next Section

Chapter 10. Objects

Earlier chapters have quietly introduced the notion of sending messages to objects. In Section 8.5.1, and in Section 9.4, a script object was treated as "an object to which one can send messages," with a handler call being such a message. In Section 9.3, we spoke of "sending the run message to a script object." The object to which a message is sent was called its "target." Section 9.7 depended upon the idea of a message being sent to a particular target. In Chapter 7, and again more fully in Chapter 9, we described the use of the of operator (or apostrophe-ess operator) or a tell block to specify a target and send it a message. It is now time to formalize these notions.

A message originates as an imperative verb, a command of some sort. But there is a distinction to be drawn between a command and a message. The command is what you say in code. The message is the communication of that command to some target, which is supposed to obey the command. For example, count is a command, and in a certain context it can cause the count message to be sent to the Finder, while in some other context it can cause the count message to be sent to Mailsmith. An object is anything that can be targeted by a message.

Sending a message to a target object is the fundamental activity of all AppleScript code; everything that is said in AppleScript code involves some target object to which some message is being sent. Furthermore, every value in AppleScript can act as such a target. In this sense, every AppleScript value is an object. (See also Section 5.4.)

This chapter deals with notions of message and target: how you specify the target object to which a message is to be sent, and how you go about actually sending it a message, along with various related syntactic features. Some relevant syntactic features, such as the keywords its and my, have already appeared informally in earlier chapters; now they too will be properly explained. The last part of this chapter is occupied with how objects may be related as attributes of one another called properties and elements, and talks about how to refer to one such object in terms of another.

    [ Team LiB ] Previous Section Next Section