# develop-24 9512 December 1995 — source transcripts, page 1

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/1)

## Transcribed source material

Machine transcriptions and image descriptions; uncertain copy may be marked [illegible]. Verify against the linked originals. Historical rights remain with the original owners.

These are transcribed excerpts, not the full publications. Open the originals for remaining pages.

### Image 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/1#scan-5169de0b372f41445215219b5d706b09b529f8c641e11bcd3ccb3d2013d63ff2)

Transcribed text:

QuickDraw 3D Tips • Advanced PowerPC Performance Profiling • MPW ToolServer

develop
The Apple Technical Journal

Issue 24 December 1995

Speeding Up whose Clause Resolution in Your Scriptable Application

Getting Started With OpenDoc Storage

Sound Secrets

Guidelines for Effective Alerts

Printing Images Faster With Data Compression

The New Device Drivers: Memory Matters

$10.00

set color of every object whose color is red to green

Image description: The cover shows a magazine masthead with an Apple logo above a flowchart-style illustration of red and green 3D shapes (spheres, cylinders, cubes, and pyramids) on an orange background, with cover story lines listed in a left column.

Reading notes: The partially cut-off cover line 'Speeding Up whose Clause Resolution in Your Scriptable Application' is printed as shown and appears to be the main story title; the word 'whose' is transcribed as printed. The 'OpenDoc' line is cropped at the right edge and appears as 'OpenDoc' with the final letter clipped. The italic script line on the illustration is partly overlapping the artwork and was transcribed as printed. Reading order of the illustration caption relative to the left column is inferred from placement.

Printed product names: develop

Printed prices: $10.00

Printed dates: December 1995 · 1995

Languages: English

[Original Image 1](https://www.vintageapple.net/files/3641ec6212423da3f8c18eae63d146b0b7b36dc19298ca5ac37574cc5ce8a9b9/3c031e85373b6962b4a2a1c1.webp)

### PDF page 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/1#scan-0ce42240c94b6e40ec3a0507e88dbfb526e34e7f8fa63556c186f27a6b36d566)

Transcribed text:

QuickDraw 3D Tips • Advanced PowerPC Performance Profiling • MPW ToolServer

develop
The Apple Technical Journal

Issue 24 December 1995

Speeding Up whose Clause Resolution in Your Scriptable Application

Getting Started With OpenDoc Storage

Sound Secrets

Guidelines for Effective Alerts

Printing Images Faster With Data Compression

The New Device Drivers: Memory Matters

$10.00

set color of every object whose color is red to green

Image description: The cover shows an orange background with a flowchart-like diagram of red and green 3D shapes (spheres, cubes, cylinders, and pyramids) connected by lines, with the caption 'set color of every object whose color is red to green' in script beside the diagram and a list of article titles down the left column.

Reading notes: The headline 'develop' is a masthead logo rather than a conventional headline; it is set as the journal title. The article title 'Speeding Up whose Clause Resolution in Your Scriptable Application' is transcribed as printed and reads oddly, so spacing and line breaks may be imprecise. Background faint text behind the diagram is not legible and was not transcribed. Reading order of the left column titles and the top banner is inferred from layout.

Printed product names: develop

Printed prices: $10.00

Printed dates: December 1995 · 1995

Languages: English

[Original PDF page 1](https://www.vintageapple.net/files/99568bc007c41b179a001c1141767ff1fc6ae62a2d601adbbfeac963ad47da0d/develop-24_9512_December_1995.pdf#page=1)

### PDF page 2

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/1#scan-d5bfc039e94b2e677b67c77f845c3222ba36de09d3175ec8802943117322d67d)

Transcribed text:

E D I T O R I A L   S T A F F
Editor-in-Cheek   Caroline Rose
Managing Editor   Toni Moccia
Technical Buckstopper   Dave Johnson
Bookmark CD Leader   Alex Dosher
Able Assistant   Meredith Best
Our Boss   Mark Bloomquist
His Boss   Dennis Matthews
Review Board   Brian Bechtel, Dave Radcliffe,
Jim Reekes, Bryan K. “Beaker” Ressler,
Larry Rosenstein, Andy Shebanow, Nick
Thompson, Gregg Williams
Contributing Editors   Lorraine Anderson,
Patria Brown, Steve Chernicoff, Toni
Haskell, Judy Helfand, Cheryl Potter,
Joan Stigliani
Indexer   Marc Savage
A R T   &   P R O D U C T I O N
Production   Lisa Ferdinandsen, Diane Wilcox
Art Direction   Paul Luiso
Technical Illustration   Mary Prusmack Ching,
John Ryan, Laurie Wigham
Formatting   Forbes Mill Press
Photography   Sharon Beals
Cover Illustration   Graham Metcalfe of
Metcalfe/Shuhert Design
ISSN #1047-0735. © 1995 Apple Computer, Inc.
All rights reserved. Apple, the Apple logo, APDA,
AppleLink, AppleScript, AppleShare, AppleTalk,
ColorSync, EtherTalk, HyperCard, HyperTalk,
LaserWriter, LocalTalk, Mac, MacApp, Macintosh,
MacTCP, MPW, MultiFinder, Newton, NewtonMail,
OpenDoc, PowerBook, Power Macintosh, QuickTime,
and TrueType are trademarks of Apple Computer, Inc.,
registered in the U.S. and other countries. A/ROSE,
develop, Dylan, eWorld, Finder, NewtonScript,
PowerTalk, QuickDraw, Sound Manager, and
ToolServer are trademarks of Apple Computer, Inc.
Adobe, Acrobat,and PostScript are trademarks of
Adobe Systems Incorporated or its subsidiaries and
may be registered in certain jurisdictions. PowerPC
is a trademark of International Business Machines
Corporation, used under license therefrom. UNIX is
a registered trademark of Novell, Inc. in the United
States and other countries, licensed exclusively through
X/Open Company, Ltd. All other trademarks are the
property of their respective owners.
T H I N G S   T O   K N O W
develop, The Apple Technical
Journal,   a quarterly publication of
Apple Computer’s Developer Press
group, is published in March, June,
September, and December.   develop
articles and code have been reviewed
for robustness by Apple engineers.
This issue’s CD.   Subscription issues
of   develop   are accompanied by the
develop Bookmark   CD. This CD contains
a subset of the materials on the monthly
Developer CD Series , available from
APDA. Included on the CD are this
issue and all back issues of   develop   along
with the code that the articles describe.
(The code is updated periodically, so
always use the most recent CD.) The
CD also contains Technical Notes,
sample code, and other documentation
and tools (these contents are subject to
change). Items referred to as being on
“this issue’s CD” are located on either
the Bookmark CD or the Reference
Library or Tool Chest edition of the
Developer CD Series . The   develop   issues
and code are also available in the
Developer Services areas on AppleLink
and eWorld and at ftp.info.apple.com.
Selected articles are on the World
Wide Web at http://www.apple.com,
in the Developer Services area.
Macintosh Technical Notes.
A designation like “(QT 4)” after a
reference to a Macintosh Technical
Note in   develop   indicates the category
and number of the Note on this issue’s
CD. (QT is the QuickTime category.)
E-mail addresses.   Most e-mail
addresses mentioned in   develop   are
either AppleLink or eWorld addresses.
We’re currently in transition: a given
AppleLink address may no longer work
by the time this issue is published.
If that happens, try the equivalent
eWorld address. On the Internet,
AppleLink address XXX translates to
xxx@applelink.apple.com, eWorld
addresss XXX to xxx@eworld.com,
and NewtonMail address XXX to
xxx@online.apple.com.
C O N T A C T I N G   U S
Feedback.   Send editorial suggestions
or comments to Caroline Rose at
AppleLink CROSE, Internet
crose@applelink.apple.com, or fax
(408)974-6395. Send technical
questions about   develop   to Dave
Johnson at AppleLink JOHNSON.DK,
Internet dkj@apple.com, CompuServe
75300,715, or fax (408)974-6395. Or
write to Caroline or Dave at Apple
Computer, Inc., 1 Infinite Loop,
Cupertino, CA 95014.
Article submissions.   Ask for our
Author’s Guidelines and a submission
form at AppleLink DEVELOP,
Internet develop@applelink.apple.com,
or fax (408)974-6395. Or write to
Caroline Rose at the above address.
Subscriptions and back issues.
You can subscribe to   develop   through
APDA (see ordering information
below) or use the subscription card in
this issue. You can also order printed
back issues from APDA. For all
subscription changes or queries,
contact APDA and   be sure to include your
name, address, and account number as it
appears on your mailing label.
The one-year U.S. subscription price is
$30 (for 4 issues and 4   develop Bookmark
CDs), or U.S. $50 in other countries.
Back issues are $13 each. These prices
include shipping and handling. For
Canadian orders, the subscription price
includes GST (R100236199).
APDA.   To order products from APDA
or receive the   Apple Developer Tools
Catalog   of all the products available
from APDA, call 1-800-282-2732 in
the U.S., 1-800-637-0029 in Canada,
(716)871-6555 internationally, or
(716)871-6511 for fax. Order
electronically at AppleLink APDA,
Internet apda@applelink.apple.com,
CompuServe 76666,2405, or America
Online APDAorder. Or write APDA,
Apple Computer, Inc., P.O. Box 319,
Buffalo, NY 14207-0319.
Printed on recycled paper
d e v e l o p

Reading notes: Transcript is intentionally empty because the exact extracted text is preserved separately; the supplied copy was used only for the other fields. No distinct headline is visible, so headline is null; section headings are not treated as a headline. The copy is editorial and legal text rather than advertising, so productNames and prices are limited to items explicitly named in the supplied copy. Publication months (March, June, September, December) and the ISSN are not listed as printedDates, since they are not clearly dates.

Printed product names: develop · Bookmark CD · Developer CD Series · Apple Developer Tools Catalog

Printed prices: $30 · U.S. $50 · $13

Printed dates: 1995

Languages: English

[Original PDF page 2](https://www.vintageapple.net/files/99568bc007c41b179a001c1141767ff1fc6ae62a2d601adbbfeac963ad47da0d/develop-24_9512_December_1995.pdf#page=2)

### PDF page 3

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/1#scan-d88eaeee28f0c4a34a303ce8e8c012e3c3cbf527867786f59636a25920897bbd)

Transcribed text:

A R T I C L E S
6   Speeding Up whose Clause Resolution in Your Scriptable Application
by Greg Anderson
Although the Object Support Library will resolve complex AppleScript clauses for you, if you take on some
of the work yourself the performance gains can be dramatic.
30   Getting Started With OpenDoc Storage   by Vincent Lo
OpenDoc storage is a departure from what you’re used to: it needs to support storing different kinds of data,
written by different part editors, in the same file or container.
45   Sound Secrets   by Kip Olson
These less obvious features of the Sound Manager will help improve your application’s use of sound.
59   Guidelines for Effective Alerts   by Paige K. Parsons
This article elaborates and expands on the guidelines for the consistent and correct usage of alerts.
72   Printing Images Faster With Data Compression   by David Gelphman
PostScript Level 2 printers can accept JPEG-compressed image data directly, which can greatly improve
printing speed. Here’s what you need to know to take advantage of this ability.
84   The New Device Drivers: Memory Matters   by Martin Minow
Using PrepareMemoryForIO to set up memory for data transfers to or from other devices is a complex —
but very important — process. This walkthrough points out traps and pitfalls along the way.
C O L U M N S
27   ACCORDING TO SCRIPT
Steps to Scriptability
by Cal Simone
A clear, step-by-step method for developing
your particular scripting implementation.
42   GRAPHICAL TRUFFLES
Making the Most of QuickDraw 3D
by Nick Thompson and Pablo Fernicola
A few tips for QuickDraw 3D that might make
your life a little easier.
56   BALANCE OF POWER
Advanced Performance Profiling
by Dave Evans
Some new and useful performance profiling
features of the PowerPC 604 processor.
69   MPW TIPS AND TRICKS
ToolServer Caveats and Carping
by Tim Maroney
All about ToolServer, a small, scriptable
application that can run MPW commands.
100   MACINTOSH Q & A
Apple’s Developer Support Center answers
queries about Macintosh product development.
110   THE VETERAN NEOPHYTE
The Right Tool for the Job
by Dave Johnson
Dynamic languages are the future of
programming. Or at least they ought to be.
112   NEWTON Q & A: ASK THE LLAMA
Answers to Newton-related development queries.
117   KON & BAL’S PUZZLE PAGE
Zoning Out
by Konstantin Othmer and Bruce Leak
The original Puzzlers return with another
merry romp through the guts of the machine.
Issue 24   December 1995
CONTENTS   1
2   EDITOR’S NOTE
3   LETTERS
123   INDEX

Reading notes: Headline is taken as the primary heading 'CONTENTS' from the table-of-contents page; the document lacks a distinct title. Reading order of article and column entries is listed by page number and may not reflect original layout.

Printed product names: Object Support Library · AppleScript · OpenDoc · Sound Manager · PostScript Level 2 · JPEG · PrepareMemoryForIO · QuickDraw 3D · PowerPC 604 · ToolServer · MPW · Newton

Printed dates: December 1995

Languages: English

[Original PDF page 3](https://www.vintageapple.net/files/99568bc007c41b179a001c1141767ff1fc6ae62a2d601adbbfeac963ad47da0d/develop-24_9512_December_1995.pdf#page=3)

### PDF page 4

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/1#scan-b2e4b7ffbfe25da2bb03ab230a4b30450d480c1083de71f7f829b20b04ff5a2d)

THE WORLD WIDE WEB IS A VALUABLE RESOURCE, BUT IT IS NOT, AFTER ALL, THE WORLD

Transcribed text:

I was visiting my friends Helen and John one night when Helen started telling me
how excited about the World Wide Web John had become. He said, “Ask me
anything at all, and I can find the answer for you.” I asked what the new U.S. postal
rate for international air mail was, knowing it had recently gone up from $.50. He
delighted over finding a Web page for the Postal Service, and quickly found the rate:
$.50. Wrong.
Later John showed me a spiffy magazine called   NewMedia , and in it an article by
longtime hypertext proponent Ted Nelson. Nelson expressed his joy that, with
HTML and the Web, hypertext’s time has finally come; we can now leave the
insanity of “paper simulation” behind and write in a way that lets information take on
its truer, interconnected form.
I found the article, and John’s enthusiasm over the Web, a bit disconcerting. The Web
is indeed a boon to humankind, but I don’t see it entirely replacing what came before.
The world’s love affair with the Web reminds me of the early days of TV (so I’m
told), when many people were sure that radio was dead. Out with the old, in with the
new. But in fact the old still had its place in the world. The virtues of the Web don’t
mean we no longer need to get information from flesh and blood people sometimes,
or from books and other media that we can hold in our hands. This may seem obvious,
but from the near hysteria surrounding the Web these days, I’m not sure it is.
A few days after my visit with Helen and John, with John still smarting from his
failed demonstration of the wonderfulness of the Web, Helen called and mentioned
that she needed the lyrics to “House of the Rising Sun.” I could hear John in the
background, tapping away as he searched for them online. I said I’d use old
technology and call back with them soon. The race was on.
After looking through my looseleaf binders full of song lyrics and a couple of big
songbooks, I dug through my tapes and found an ancient recording of Woody
Guthrie singing the song. After lots of rewinding and transcribing, I had more verses
than Helen ever dreamed existed. When I triumphantly called back, John (several
levels down in the Library of Congress) was mortified.
While old technology will typically not beat Web browsers in the search for nuggets
of information, it will not die, and it deserves proper respect. There are some things
we’ll learn only through person-to-person contact. And there are emotions we’ll
experience only from hearing or reading good old-fashioned sequential deliveries.
The World Wide Web is a valuable resource, but it is not, after all, the world.
CAROLINE ROSE
d e v e l o p   Issue 24   December 1995 2
EDITOR’S NOTE
CAROLINE ROSE   (AppleLink CROSE) enjoys
editing
develop so much that she fears she may
forget to retire someday. She started out in
technical writing and editing eons ago,
eventually moving on to programming and even
management before returning to her original
calling. What seems to be calling her now is
the sea: Her last vacation took her up to Puget
Sound (stalking wild elk on the Olympic Peninsula
on the way), and her next will be in a sailboat in
the Bahamas. She may even have the opportunity
to cruise the Pacific in a few years but she’s not
sure she’ll be ready to leave
develop, her cat, or
terra firma.•
Caroline Rose
Editor

Reading notes: Headline is inferred from the article's closing line; the primary printed heading was not clearly marked in the supplied copy. Dates in the magazine header and issue line appear as 'Issue 24' and 'December 1995'; reading order of the masthead is uncertain.

Printed product names: NewMedia · HTML · House of the Rising Sun

Printed prices: $.50

Printed dates: December 1995 · Issue 24

Languages: English

[Original PDF page 4](https://www.vintageapple.net/files/99568bc007c41b179a001c1141767ff1fc6ae62a2d601adbbfeac963ad47da0d/develop-24_9512_December_1995.pdf#page=4)

### PDF page 5

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/1#scan-c64a836fd33964c9af0cc75d3a72e7e5b22e70d0e3a169da3f8dfe3baa63056a)

Transcribed text:

PROJECTDRAG IMPRESSES
I’ve been working with Tim Maroney’s
ProjectDrag (Issue 23, “MPW Tips and
Tricks: Customizing Source Control
With SourceServer”), and I’m very
impressed. I’ve never found an adequate
way of using a revision control system
on the Macintosh (Projector is too
clumsy to use when you’re developing
with CodeWarrior), and I had written
off SourceServer completely after I had
such a miserable experience with it
under Symantec C++ 7.0. But Tim’s
article and software have given that dog
some new tricks. His programs are easy
to use and powerful at the same time.
Thank you very much for publishing
Tim’s work in this issue, and I hope to
see more about ProjectDrag in the
future.
— Phil Sulak
Thanks for the feedback; we’re happy to
know that you find ProjectDrag useful.
There were a few problems with the previous
version of ProjectDrag, so on this issue’s CD
you’ll find a new version with a few bug
fixes and enhancements. Also, the previous
version was missing the makefile; it’s now on
the CD.
— Caroline Rose
QTMA
I read the article on QTMA by David
Van Brink in Issue 23, and have a few
additional questions. As Director of
Audio for Human Code (an Austin
multimedia developer), I’m looking for
a way to convey an other-worldly quality
to the soundscape of a CD-ROM title
we’re developing.
First, is QTMA supported on the PC
platform? If it only works on the Mac
OS platform, I’m back to the drawing
board.
Also, is it possible to seed a bank of
custom-designed samples to be played
using standard MIDI files with QTMA?
If so, is there a developer’s guide
available for programming within
QTMA?
— John Malcolm Smith
First of all, you’ve probably noticed that
there were no changes to the Music
Architecture in QuickTime 2.1 after all.
These changes have been delayed until the
next release of QuickTime (which should
ship by early 1996). The code on this issue’s
CD has been revised so that it compiles with
the 2.0 or 2.1 headers.
On the PC side, QuickTime music tracks
are supported, but only inside movies. So,
compose your score on the Macintosh,
import it into a QuickTime movie using
MoviePlayer, and then save it flattened with
the “Playable On Non-Apple Computers”
box checked. This movie will play through
Windows’ multimedia extensions, according
to its MIDI setup.
As far as adding your own instruments,
you should be able to do this in the next
QuickTime release in two ways: by dropping
a component into the System Folder, to
make a sound library available to all
applications, or by inserting a sound into the
music track of a particular movie.
— David Van Brink
PUZZLE PAGE DOESN’T STINK
Re Lance Drake’s letter in Issue 22
entitled “Puzzle Page Stinks”: I   strongly
LETTERS
LETTERS   3
IF YOU LIKE US, LET US KNOW
What do you like, or not like, about
develop
(besides the Puzzle Page)? We welcome your
letters, especially regarding articles published in
develop. Letters should be addressed to Caroline
Rose — or, if technical
develop-related questions,
to Dave Johnson — at AppleLink CROSE or
JOHNSON.DK. Or you can write to Caroline or
Dave at Apple Computer, Inc., 1 Infinite Loop,
Cupertino, CA 95014. All letters should include
your name and company name as well as your
address and phone number. Letters may be
excerpted or edited for clarity (or to make them
say what we wish they did).•

Reading notes: Section headings such as QTMA and PUZZLE PAGE DOESN'T STINK appear mid-text, so reading order between letters and replies may be ambiguous Letter text in the Puzzle Page section is truncated mid-sentence after 'I strongly'

Printed product names: ProjectDrag · Projector · CodeWarrior · SourceServer · Symantec C++ 7.0 · QTMA · QuickTime 2.1 · QuickTime · MoviePlayer · Windows · develop · AppleLink

Printed dates: Issue 23 · Issue 22 · early 1996 · 2.0 · 2.1

Languages: English

[Original PDF page 5](https://www.vintageapple.net/files/99568bc007c41b179a001c1141767ff1fc6ae62a2d601adbbfeac963ad47da0d/develop-24_9512_December_1995.pdf#page=5)

### PDF page 6

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/1#scan-072a123670a5e80fc7e088ac9c78a62a1644217d6ee4a7b152262eb30b650a77)

Transcribed text:

disagree. The Puzzle Page is the first
article I read. From it I’ve learned new
debugging tactics, and picked up cool
MacsBug tricks and how to do more
than just “G” from MicroBug. The fact
that the “scoring” shouldn’t be taken
literally is obvious; after all, KON &
BAL never get the answer till 10 or less.
Don’t let one humorless whiner ruin a
good thing.
Keep up the good work;   develop   is a
great resource.
— Steve Palmen
I wanted to let you know how much I
enjoy the Puzzle Page. I just graduated
and was lucky enough to land a job
programming on the Mac. Issue 22 is
my first and I’ve already looked back at
all of the previous Puzzles because I
enjoy reading about the deepest, darkest
Mac knowledge that I hope to stuff into
my brain one day. It’s refreshing to have
a technical journal that’s not afraid to
crack a joke every couple of pages. I
haven’t felt offended or mocked by your
Puzzle Page.
— Matt Glazier
I just want to let you know that there
are people out here who read and enjoy
the Puzzle Page. I try to follow every
twist and turn in the logic that leads to
the final result. I’ve tracked down a few
bugs in my own code that were complex
and obscure enough to end up on the
Puzzle Page, and it’s nice to see the
steps someone else follows.
— David Shayer
. . . WELL, MAYBE JUST A LITTLE
The letter from Lance Drake in Issue
22 about the Puzzle Page was, as you
wrote, a surprise to you. To me it wasn’t.
First I would like to state that the
Puzzle Page is by far the best column in
develop   — technically very interesting
and also amusing. This explains the
good feedback you receive on it. Yet the
“scoring” tables are indeed belittling,
elitist, and intellectually arrogant. Even
worse, they are offending. This is a
detail, but it fully explains and justifies
Mr. Drake’s angry letter.
— Adriaan van Os
Many thanks for all the work you put
into   develop.   The production qualities
are superb. I have only one complaint:
get rid of KON & BAL’s Puzzle Page.
I always feel depressed after reading it.
— Andrew Trevorrow
FINGER-CODED BINARY
VARIATION
I’d like to comment on Tobias Engler's
Finger-Coded Binary column in Issue
21. Although I agree with most of what
he said, Tobias’s approach, the 10-bit
model, is far less natural than it needs to
be. I find it much easier (at least more
natural) to work with hands flat on the
side of a table, using all fingers except
thumbs — this results in the more
commonly used 8-bit model. You can
then use your thumbs for other things,
such as branch prediction, status
registers, or even complex instruction
execution.
I have one advantage over many people.
The fact that I’m missing part of my
right thumb enables me to do fractions.
No other digital system I know of can
do 0, 1/2, and 1 digits.
— Martin-Gilles Lavoie
There’s much more to the 10-bit model
than you seem to realize. Have you ever
had somebody tell you “You can eat as many
Snickers bars as you can count on your
hands”? Probably not. You wouldn’t want to
stop at 256, would you?
Concerning your fractional thumb: Your
technological advantage over conventional
digital systems will undoubtedly attract
many copyists, which may result in a lot of
unnecessary bloodshed. My advice to you is
go and get a patent!
— Tobias Engler
d e v e l o p   Issue 24   December 1995 4

Reading notes: Possible spacing artifact in 'develop   is' and 'develop   —' in running text, reading order is otherwise clear

Printed product names: develop · MacsBug · MicroBug · Snickers

Printed dates: December 1995 · Issue 22 · Issue 21 · Issue 24

Languages: English

[Original PDF page 6](https://www.vintageapple.net/files/99568bc007c41b179a001c1141767ff1fc6ae62a2d601adbbfeac963ad47da0d/develop-24_9512_December_1995.pdf#page=6)

### PDF page 7

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/1#scan-d0a5918797d7c592a6919b7cc982dafe3f4f30f19394a19d53e7ff2073ba9065)

Speeding Up whose Clause Resolution In Your Scriptable Application

Transcribed text:

The Object Support Library provides convenient mechanisms for
scriptable applications to support complex expressions that may return
multiple results (such as   every item of container "b" whose name
contains "a" ). However, the performance of applications that rely on
the default behavior is nowhere near what it could be if the application
took on some of the work itself. This article shows you how to gain
ten- to a hundred-fold increases in the performance of   whose   clause
resolution in your scriptable application. If your application is not yet
scriptable, you’ll find that the foundation classes presented in this article
do most of the work required to support scripting.
One of the greatest strengths of AppleScript is its built-in ability to do complex
operations on groups of objects in a single line of script. For example, suppose you
have a set of shapes in a scriptable drawing program, and you’d like to change the
color of all the red shapes to green. In conventional programming languages, you’d
need to write a loop that iterates over each object in the set, tests to see if its color is
red, and then does a “set color to green” command for each red object that was
found. Using AppleScript, you can do the same operation with the single statement
set color of every shape whose color is red to green . In that statement,   every
shape whose color is red   is called a   whose   clause , and it’s the inclusion of   whose
clauses that makes AppleScript the powerful language it is.
You may at first doubt that using a   whose   clause is much better than writing the
equivalent script with a loop. After all, the direction of modern processor design has
been toward simplicity of the instruction set; RISC chips are able to gain incredible
performance improvements by doing optimizations that aren’t possible in CISC
chips. Also, when all is said and done, the   whose   clause must finally execute the same
loop-and-compare algorithm that you’d be forced to use if you wrote the script with
the basic flow-of-control script commands, such as   do - while   and   if - then .
Using a   whose   clause is, however, much more efficient than the alternative.
AppleScript is based on the client/server paradigm: typically your script, the client,
will be running in one application (usually the Script Editor or a script saved as a
miniapplication), with the application being scripted acting as a server. In this
GREG ANDERSON
Speeding Up whose Clause Resolution
In Your Scriptable Application
d e v e l o p   Issue 24   December 1995 6
GREG ANDERSON   is enjoying the hot days of
late summer as he writes this, but by the time this
issue is in your hands, he should be back on the
ski slopes earning his nickname, “Air Bear.” Greg
spends most of his skiing time looking for some
protrusion to jump or fall off of while wearing
his favorite polar bear hat. He sometimes works,
too; he recently moved to Japan to work on
international software for Apple Technologies in
Tokyo.•

Reading notes: Line-break hyphenation in 'ten- to a hundred-fold' and 'hundred-fold' is ambiguous in the extracted text. Author byline and sidebar text appear interleaved with the article body, so reading order around 'GREG ANDERSON' may be uncertain.

Printed product names: AppleScript

Printed dates: December 1995 · Issue 24

Languages: English

[Original PDF page 7](https://www.vintageapple.net/files/99568bc007c41b179a001c1141767ff1fc6ae62a2d601adbbfeac963ad47da0d/develop-24_9512_December_1995.pdf#page=7)

### PDF page 8

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/1#scan-8aedf9595f5fb61acd2f6d464cb4e4a1aa2e669caa2fa5482430de9d8086e554)

Transcribed text:

situation, each script command that’s directed at the scriptable application needs to be
transferred between the two applications. A   whose   clause is a single script command,
but with the loop approach many commands would need to be sent. Furthermore,
AppleScript allows the scriptable application to reside on a different machine than the
application running the script; if your script is running on a machine in Cupertino,
California, and the server is on, say, Mars, reducing the number of round-trip
messages would have a profound impact on the performance of the script. Remember,
you can currently get only about 30 round-trip Apple events per second, so even if
you aren’t sending data to Mars, you’ll still do a lot better with fewer events than with
many.
There’s another, similar reason that using   whose   clauses is superior to the equivalent
loop-based script: AppleScript compiles scripts into byte codes that are interpreted
during execution, whereas the individual script commands (once interpreted) are
processed by a scriptable application typically written in a language that’s compiled
into machine code (be it 680x0 or PowerPC™). The loop-and-compare script will
execute several lines of script for every item that’s compared, whereas the   whose
clause is but a single line of script that triggers processing in a compiled application.
It should be quite clear which will take less time to execute.
The Object Support Library (OSL) — the library that provides the API you use to
make your application scriptable — enables your application to support   whose
clauses without requiring you to write a lot of additional code. You only need to
provide an object-counting function and an object comparison function, and the OSL
can resolve   whose   clauses for you. Since supporting   whose   clauses allows script
writers to write more efficient scripts, you should always do at least this much.
However, there are two other features of the OSL that can vastly increase the
performance of scriptable applications but are often ignored by application writers:
whose   clause resolution   (a way for your application to find the objects that match a
whose   test without using the OSL) and   marking   (a mechanism for efficiently
handling collections of objects, such as those satisfying a   whose   clause). Using   whose
clause resolution, with the help of marking, will enable you to get the most out of
your scriptable application. Resolving   whose   clauses can be a bit tricky, but with a
little help from this article, you’ll be on your way in no time.
If your application is not yet scriptable, you’ll find the sample code included with this
article (and on this issue’s CD) to be invaluable in getting you up and running —
particularly since it contains a lot of reusable code.
AN OVERVIEW OF THE OSL
Good descriptions of the OSL can be found in the   develop   articles “Apple Event
Objects and You” in Issue 10 and “Better Apple Event Coding Through Objects” in
Issue 12. If you need a quick review of the OSL and you don’t feel like putting down
this issue of   develop   to dig through your back issues, read on. If you can already
generate tokens and resolve object specifiers in your sleep, by all means skip ahead
to the next section.
When AppleScript is processing a script command such as   delete paragraph 2 of
document "sample" , it converts the command into an Apple event which it sends
to the scriptable application that’s referenced by the script. The Apple event’s event
class and message ID together specify the verb of the operation being performed —
in this case   delete . The object being operated on is passed in the keyDirectObject
parameter of the Apple event, which is called, naturally enough, the   direct parameter
of the event.
SPEEDING UP WHOSE CLAUSE RESOLUTION IN YOUR SCRIPTABLE APPLICATION   7

Printed dates: Issue 10 · Issue 12

Languages: English

[Original PDF page 8](https://www.vintageapple.net/files/99568bc007c41b179a001c1141767ff1fc6ae62a2d601adbbfeac963ad47da0d/develop-24_9512_December_1995.pdf#page=8)

### PDF page 9

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/1#scan-c75b625034b07bd891df22843cd14ea37c8210f0a9be608e2f5fa4f0404ce707)

Transcribed text:

The direct parameter is almost always an   object specifier   — a descriptor of type
typeObjectSpecifier — although in some cases it may be something else. For
example, in addition to object specifiers, the Scriptable Finder accepts alias records
and file specifications in the direct parameter of events sent to it. If the direct
parameter of an event is not of type typeObjectSpecifier, you’re on your own to
convert it into some format that’s understood by your event handler. For descriptors
that are of this type, though, all you need to do is call the function AEResolve, and
the OSL will step in and help your application   resolve   the object specifier — that is,
locate the Apple event objects it describes.
Object specifiers are resolved through   object accessor callbacks   that your application
installs to allow the OSL to communicate with your application during object
resolution. The accessor callbacks must take the description of the object requested
by the OSL (for example,   document "sample" ) and return a   token   that describes the
object in terms that the application can understand (for example, a pointer to a
TDocument object). Tokens are passed back to the OSL in an AEDesc, a structure
that contains a 32-bit descriptor type and a handle. Your application has complete
control over what it stores in the token, as long as the AEDesc is valid (that is, it was
created with AECreateDesc).
When the OSL calls your application’s object accessor callbacks, it always passes
either a token that represents the containing object (which it got from an earlier call
to one of your object accessors) or a representation of the default container of the
application, which is also called the null container of the application. So, to resolve
the object specifier   paragraph 2 of document "sample" , the OSL first asks for
document "sample"   from the null container. Then it asks the application to provide
a token for   paragraph 2   from the token the application provided in response to the
request for   document "sample" . The token that the application provides for
paragraph 2   is returned as the result of the AEResolve call; the application will
presumably use this token to process the Delete event.
Resolving object specifiers   is explained in Chapter 6 of
Inside Macintosh:
Interapplication Communication. A figure illustrating the process of resolving object
specifiers is on page 6-6.•
MARKING
Inside Macintosh: Interapplication Communication   describes marking as a mechanism
whereby items to be operated on are marked with some flag during resolution (that
is, from the callbacks made by the AEResolve function); then, during execution, each
marked item is processed and the mark is cleared. As described, marking doesn’t
sound very interesting and appears to be useful only in fringe cases.
Marking is actually very well suited for use as a general-purpose collection mechanism
whenever the OSL needs to group tokens together to process an object resolution.
For example, if the OSL is resolving the   whose   clause   every shape whose color is
red   and there are multiple red shapes, the result of the call to AEResolve must be a
collection of all the tokens that represent red objects. If your application supports
marking, the OSL asks your application to create a special   mark token   to represent
this collection. After your application provides the OSL with a mark token, the OSL
will ask your application to add the tokens it provided for the red shapes to the mark
token’s collection. When AEResolve completes, the mark token is returned as the
result of the resolution.
If your application doesn’t support marking, the OSL will create collections of tokens
for you by copying the data from your tokens into a descriptor list (an AEDescList).
d e v e l o p   Issue 24   December 1995 8

Reading notes: Source ends with a page marker and footer 'd e v e l o p Issue 24 December 1995 8' that may not be part of the body text.

Printed dates: 1995

Languages: English

[Original PDF page 9](https://www.vintageapple.net/files/99568bc007c41b179a001c1141767ff1fc6ae62a2d601adbbfeac963ad47da0d/develop-24_9512_December_1995.pdf#page=9)

### PDF page 10

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/1#scan-89817a04744fa0e056bb81d71e52b106aab6a6aa6c510bd0aac8a9ad627c1938)

Transcribed text:

It calls the standard Apple Event Manager routines for creating descriptor lists, which
copy the data out of the data handle of the AEDesc and then store the token data
somewhere inside the data handle of the descriptor list; the descriptor type of the
AEDesc is similarly encapsulated.
Dealing with descriptor lists of tokens can be inconvenient, particularly if your
application already supports collections of objects in some other way. The OSL
marking mechanism gives you the flexibility to handle collections in any way that’s
convenient for your application.
To support marking, you must pass the flag kAEIDoMarking to AEResolve and
implement the three marking callbacks that are passed to AESetObjectCallbacks: the
create-mark-token callback (called just a “mark-token callback” in   Inside Macintosh ),
the object-marking callback, and the mark-adjusting callback. The create-mark-token
callback doesn’t need to do anything more than create an empty mark token. The
OSL will dispose of this token as usual by calling your token disposal callback when
the token is no longer needed. Listing 1 shows an example implementation of a
create-mark-token callback.
The object-marking callback is passed a mark token created from the create-mark-
token callback and some other token created by one of your application’s object
accessor callbacks. Your object-marking callback should add a copy of the other token
into the mark token (or apply a reference count to the token being added), because
the OSL will dispose of the token added to your collection shortly after calling your
object-marking callback. Listing 2 shows one implementation of an object-marking
callback.
The mark-adjusting callback is called to remove (“unmark”) tokens from the collection.
Oddly enough, its parameters specify which tokens in the range to keep; all tokens
outside the specified range should be discarded.
Implementing the marking callbacks is trivial. The only real work involved in
supporting marking is handling collections of tokens when they’re ultimately received
by one of your event handlers (handling Move events, for example). The amount of
code required to handle the marking callbacks and maintain your own collections is
minimal; in fact, the time you’ll save by not having to hassle with descriptor lists of
tokens will more than make up for the implementation cost. You’ll find more
information on handling collections of tokens later in this article. Don’t put off
SPEEDING UP WHOSE CLAUSE RESOLUTION IN YOUR SCRIPTABLE APPLICATION   9
Listing 1.   Create-mark-token callback
pascal   OSErr   CreateMark(AEDesc   containerToken,   DescType   desiredClass,
AEDesc*   markTokenDesc)
{
TMarkToken*   markToken;
markToken   =   new   TMarkToken;
markToken->IMarkToken();
markTokenDesc->descriptorType   =   typeTokenObject;
markTokenDesc->dataHandle   =   markToken;
return   noErr;
}

Reading notes: Listing 1 code excerpt is mid-article and its surrounding context is not fully legible in the supplied copy

Languages: English

[Original PDF page 10](https://www.vintageapple.net/files/99568bc007c41b179a001c1141767ff1fc6ae62a2d601adbbfeac963ad47da0d/develop-24_9512_December_1995.pdf#page=10)

### PDF page 11

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/1#scan-99a2b6fe2d2030118407f22ba1f51b09d5fb3fa6af9f75d8c9856dd52ef4a519)

Transcribed text:

marking as an optimization to be done later; incorporate it into the design of your
application from the very beginning.
For more details on the marking callbacks,   see
Inside Macintosh:
Interapplication Communication, pages 6-53 to 6-54.•
WHOSE CLAUSE RESOLUTION
The only thing that a scriptable application needs to do to support   whose   clauses is
provide an object-counting function and an object comparison function — the OSL
will do the rest of the work. When the OSL does a   whose   clause resolution, however,
it has no choice but to iterate over every element in the search set, repeatedly calling
your application’s object accessor, object comparison, and token disposal callbacks.
Huge performance gains can be realized if you resolve   whose   clauses yourself,
because you’ll avoid the overhead the OSL requires to make these callbacks.
Passing the flag kAEIDoWhose to AEResolve tells the OSL that you’ll resolve the
whose   clause yourself. The OSL calls your object accessor with the key form
formWhose (see Listing 3). The key data is a   whose   descriptor — that is, an AERecord
that describes the comparison to be performed in the search. Your application should
interpret the   whose   descriptor and test every element of the container token to see
if it matches the specified criteria. If the   whose   descriptor is too complex for your
application, you can return the error code errAEEventNotHandled from your object
accessor, and the OSL will do the resolution for you with the default techniques. This
is very useful, as it allows you to maximize the performance of the most common
whose   clauses, yet still support complex   whose   descriptors that are likely to be
encountered only rarely.
The astute reader will notice that the scheme presented in Listing 3 is very similar to
the process that the OSL goes through to resolve   whose   clauses. There are still
optimizations that could be made to speed up the resolution further, but we’ll get to
those later. To resolve   whose   clauses as shown in Listing 3, your application must be
able to do the following:
d e v e l o p   Issue 24   December 1995 10
Listing 2.   Object-marking callback
pascal   OSErr   TAccessor::AddToMark(AEDesc   tokenToAdd,   AEDesc
markTokenDesc,   long   markCount)
{
AEDesc   copyOfToken;
TMarkToken* markToken;
//   We   know   that   the   OSL   will   only   give   us   mark   tokens   created   with
//   our   create-mark-token   callback,   but   real   code   would   do   a   test
//   before   typecasting.
markToken   =   (TMarkToken*)   markTokenDesc.TokenObject();
//   Add   a   copy   of   the   token   to   the   collection,   because   the   OSL   will
//   dispose   of   tokenToAdd   after   passing   it   to   you.   A   reference-
//   counting   scheme   is   good   here.
copyOfToken   =   CloneToken(tokenToAdd);
markToken->AddToCollection(copyOfToken);
return   noErr;
}

Reading notes: Source text is a technical programming article excerpt with no advertised products, prices, or headline. Printed date 'Issue 24 December 1995' appears in running footer.

Printed dates: 1995

Languages: English

[Original PDF page 11](https://www.vintageapple.net/files/99568bc007c41b179a001c1141767ff1fc6ae62a2d601adbbfeac963ad47da0d/develop-24_9512_December_1995.pdf#page=11)

[Next transcribed scans](https://www.vintageapple.net/transcripts/media/va-develop-24-9512-december-1995-6db47b/2.md)
