Skip to Content
AppleScript: The Definitive Guide
book

AppleScript: The Definitive Guide

by Matt Neuburg
November 2003
Beginner to intermediate
480 pages
15h 3m
English
O'Reilly Media, Inc.
Content preview from AppleScript: The Definitive Guide

Target

At every moment in AppleScript code, you are speaking to some object. That object is the target, to which, unless you specify otherwise, all messages will be sent. The target can be implicit, or you can specify an explicit target. Knowing what object is the target, and how to specify a desired target, is very important to your successful use of AppleScript.

The implicit target is the current script or script object. In this code, the implicit target of set is the script itself:

set x to 5

In this code, the implicit target of set is the script object myScript:

script myScript
        set x to 5
end script

There are two ways to specify an explicit target. Not coincidentally, they bear a strong resemblance to the two ways of accessing a script object’s top-level entities (Chapter 9). You can specify an explicit target:

  • With the of operator or its synonyms. A synonym for of is in. (I never use this.) Another synonym, for most purposes, is the apostrophe-ess operator: instead of saying x of y, you can say y's x.

    The of operator specifies the target for just a single expression, and overrides all other targets, explicit or implicit.

  • With a tell block. Instead of an actual block, one may apply tell to a single command (Section 12.3), but this is still just a special case of a tell block.

    In the context of a tell block, the object specified in the announcement is the default target for everything you say. This can be overridden by specifying a different target, using either an embedded tell ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

AppleScript in a Nutshell

AppleScript in a Nutshell

Bruce W. Perry

Publisher Resources

ISBN: 0596005571Catalog PageErrata