# Macintosh Programming Primer: Inside the Toolbox Using THINK’s Lightspeed C — source transcripts, page 1

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-macintosh-programming-primer-1989-ae17ab/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-macintosh-programming-primer-1989-ae17ab/1#scan-20014a1fd55f589bbc81f01bbc8eded174cd460403cc3330a5994805c8cb2310)

Macintosh Programming PRIMER

Transcribed text:

Addison-Wesley Publishing Company, Inc.
DAVE MARK
CARTWRIGHT REED
SOFTWARE ETC
601-7045
ETC. PRICE $24.95
MACP ROGPRMR
143-9H
1503 0413
Macintosh® Programming PRIMER
Inside the Toolbox Using THINK's LightspeedC™
Foreword by Stephen Chernicoff

Image description: A book cover with a blue top band holding publisher and author names, a tan background, and the large title 'Macintosh Programming PRIMER' where each letter of PRIMER sits on a different colored square, plus a Software Etc. price sticker in the upper right.

Reading notes: The price sticker text is faint and the price '$24.95' is partly obscured and uncertain; it may read '$24.95' or similar. Sticker codes '601-7045', 'MACP ROGPRMR', '143-9H', and '1503 0413' are hard to read and may be inaccurate. The ETC. PRICE line appears partly overwritten by a handwritten or stamped mark.

Printed product names: Macintosh Programming PRIMER

Printed prices: $24.95

Languages: English

[Original Image 1](https://www.vintageapple.net/files/04a3652b04aedb3f01c480f327d8ce06ba8b91436ee11f22c3f2c46a9b2c4cce/ea88a77591d5885a4878e5a2.webp)

### PDF page 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macintosh-programming-primer-1989-ae17ab/1#scan-111ef0f6b775fb1476f6d3dc3fc6c8a1ad400c98fbec1728632f9c0d3ded88cb)

Macintosh Programming PRIMER

Transcribed text:

▲▼ Addison-Wesley Publishing Company, Inc.

DAVE MARK
CARTWRIGHT REED

SOFTWARE ETC
601-7045
ETC. PRICE $24.95
MACPROGPRMR
143-9H
15030413

Macintosh®
Programming
PRIMER

Inside the Toolbox Using
THINK's LightspeedC™

Foreword by Stephen Chernicoff

Image description: A book cover with a blue top band holding the publisher logo and author names, a tan background, a large black title with each letter of PRIMER set on a different colored square, and a software store price sticker in the upper right.

Reading notes: The store sticker price reads as '$24.95' but the digits are partly obscured and blurred, so the amount is uncertain. The sticker code '15030413' and item codes '601-7045' and '143-9H' are small and partly faded; exact characters may be wrong. The sticker text 'MACPROGPRMR' is hard to read and may be misspelled. Reading order of the sticker fields is inferred from layout.

Printed product names: Macintosh Programming Primer

Printed prices: $24.95

Printed dates: 15030413

Languages: English

[Original PDF page 1](https://www.vintageapple.net/files/8422354162de304f3850e3789fc87f47213f4daf7fa93443fc6d6ca0ee164374/Macintosh_Programming_Primer_1989.pdf#page=1)

### PDF page 2

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macintosh-programming-primer-1989-ae17ab/1#scan-ab76c7f30eee3d609e358048039ad0ca763811acaf1810d55153b495ac7f4f56)

Macintosh® Programming Primer

Transcribed text:

Macintosh®
Programming
Primer
Inside the Toolbox   Using
THINK's LightspeedC™
Dave Mark   Cartwright Reed
• •• Addison-Wesley   Publishing   Company, Inc.
Reading, Massachussets   Menlo Park,   California   New   York
Don Mills, Ontario   Wokingham, England   Amsterdam   Bonn
Sydney   Singapore   Tokyo   Madrid   San   Juan

Reading notes: Transcript is set to empty because the exact extracted text is preserved separately. Supplied copy prints 'Massachussets', which is a misspelling of 'Massachusetts' as printed. Layout and reading order are inferred from the supplied line breaks, not confirmed from the image. No prices or dates appear in the supplied copy.

Printed product names: Macintosh® · THINK's LightspeedC™

Languages: English

[Original PDF page 2](https://www.vintageapple.net/files/8422354162de304f3850e3789fc87f47213f4daf7fa93443fc6d6ca0ee164374/Macintosh_Programming_Primer_1989.pdf#page=2)

### PDF page 3

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macintosh-programming-primer-1989-ae17ab/1#scan-b017e027ba9aef51036b87c9d065bc3f04501ae941196c567166b687eda89a3a)

Transcribed text:

I To Kate and Deneen
Many of the designations used by manufacturers and sellers
to distinguish their products are claimed as trademarks.
Where those designations appear in this book, and   Addison-
Wesley was aware of a trademark claim, the designations
have been printed in initial caps or all caps-for example,
Macintosh, THINK C.
Library of Congress Cataloging-in-Publication Data
Mark, Dave.
Macintosh programming primer.
Includes index.
1. Macintosh (Computer)--Programming.
2. C (Computer program language). I. Reed,
Cartwright. II. Title.
QA76.8.M3M368   1989   005.265   88-34992
ISBN   0-201-15662-8
Copyright © 1989 by Dave Mark and Cartwright Reed
All rights reserved. No part of this publication may be
reproduced, stored in a retrieval system, or transmitted, in
any form or by any means, electronic, mechanical,
photocopying, recording, or otherwise, without the prior
written permission of Addison-Wesley. Printed in the
United   States   of America.
ABCDEFGHIJ-AL-89
First Printing, April 1989

Reading notes: Source appears to be front matter of a book; no advertised products or prices present. Printed date 88-34992 is a Library of Congress control number rather than a publication date.

Printed product names: Macintosh · THINK C

Printed dates: 1989 · April 1989 · 88-34992

Languages: English

[Original PDF page 3](https://www.vintageapple.net/files/8422354162de304f3850e3789fc87f47213f4daf7fa93443fc6d6ca0ee164374/Macintosh_Programming_Primer_1989.pdf#page=3)

### PDF page 4

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macintosh-programming-primer-1989-ae17ab/1#scan-99a886758dbb018d8f8160883e851016f4b76e606141350f5754d5a3ea9b6d19)

Transcribed text:

Contents
Acknowledgments   vii
Foreword   Stephen Chernicoff   ix
1   Introduction   1
The Macintosh Vision   2
About the Book   6
How to Use This Book   19
What You Need to Get Started   20
Ready,   Set...   21
2   SettingUp   23
Installing THINK C   24
Macintosh Programming Issues   26
The Hello, World Program   35
In Review   42
3   Drawing on the Macintosh   43
Introduction   44
Window Management   48
Drawing in Your Window: The QuickDraw Toolbox Routines   53
The QuickDraw Programs   60
Hello2   60
Walking through the Hello 2Code   66
Variants   69
Mondrian   73
iii

Printed product names: THINK C

Languages: English

[Original PDF page 4](https://www.vintageapple.net/files/8422354162de304f3850e3789fc87f47213f4daf7fa93443fc6d6ca0ee164374/Macintosh_Programming_Primer_1989.pdf#page=4)

### PDF page 5

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macintosh-programming-primer-1989-ae17ab/1#scan-c919784cb0f78bbc98e57eaf11833c614a78e3cbe1de91e8866ec7e06f78f07e)

Transcribed text:

iv   Contents
Walking through the Mondrian Code   76
Variants   79
ShowPICT   84
Walking through the   ShowPICT   code   88
Variants   92
Screen Saver: The Flying Line Program   92
Walking through the Flying Line   Code   96
In Review   102
4   The Event Mechanism   103
Event Types   105
The Structure of a Mac Program: New and Improved   107
Retrieving Events from the Event Queue   109
Handling Events   112
EventTutor: The Return of Show PICT   113
Walking through the EventTutor   Code   125
In Review   142
5   Menu Management   143
Menu Components   144
The   Pull   Down Menu   146
The Hierarchical Menu   146
The   Pop-Up   Menu   147
Other   Kinds of Menus   147
Putting Menus into Your Programs   148
Timer   149
Setting   Up   the   Project   150
Timer   Code   163
Walking through the Timer Code   172
Zinger   182
Walking through   Zinger   190
In Review   196
6   Working with Dialogs   197
How Dialogs Work   199
Dialog Items: Controls   201
Other   Dialog Items   204
Working with Alerts   206
Adding Dialogs to Your Programs   207
The Notification Manager   212
Reminder   215
Walking through the Reminder Code   244
In Review   261
7   Toolbox Potpourri   263
Keeping Track of Windows: WindowMaker   264
The Scrap Manager   295
ShowClip   297

Languages: English

[Original PDF page 5](https://www.vintageapple.net/files/8422354162de304f3850e3789fc87f47213f4daf7fa93443fc6d6ca0ee164374/Macintosh_Programming_Primer_1989.pdf#page=5)

### PDF page 6

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macintosh-programming-primer-1989-ae17ab/1#scan-05bed42c1b4a9e5ca27afe0c24a8a2c5cb8343148667f5403ec31b20cc5da94f)

Transcribed text:

Contents   v
Inside the Printing and File Managers   307
Using   the Printing Manager   312
PrintPICT   312
Scroll   Bars! We're Gonna Do   Scroll   Bars!   327
Pager   329
The   Sound   Manager   347
Sounder   347
Walking through the   Sounder   Code   352
In Review   354
8   Using   ResEdit   355
The Finder Resources   357
Completing a Standalone Application: Hello2 Revisited   358
Notes on   Using   ResEdit   360
The ResEdit Tutorial: Installing the Finder Resources   366
Rebuilding the Desktop   384
Minimalist, the ResEdit Program   391
In Review   395
9   The Final Chapter   397
Macintosh Periodicals   398
The Essential   Inside Macintosh   398
Apple Technical References   400
Apple's Developer Programs   402
Macintosh Developer Technical   Support   and AppleLink   402
Software   Development Tools   403
To Boldly Go   404
Appendix A   Glossary   405
Appendix B   Code Listings   419
Chapter   2,   Hello.c   420
Chapter   3,   Hello2.c   420
Chapter   3,   Mondrian.c   421
Chapter   3,   ShowPict.c   423
Chapter   3,   Flying Line.c   425
Chapter   4,   EventTutor.c   428
Chapter   5,   Timer.c   436
Chapter   5,   Popup.c   444
Chapter   6,   Reminder.c   448
Chapter   7,   WindowMaker.c   460
Chapter   7,   ShowClip.c   466
Chapter   7,   PrintPICT.c   469
Chapter   7,   Pager.c   472
Chapter   7,   Sounder.c   478
Appendix C   THINK C Command Summary   481
The   Project   Menu   482
The File Menu   485

Reading notes: Primary heading not clearly identifiable from the supplied copy; headline set to null.

Printed product names: THINK C · ResEdit · Inside Macintosh · Hello2 · PrintPICT · Sounder · Minimalist · AppleLink · Mondrian

Languages: English

[Original PDF page 6](https://www.vintageapple.net/files/8422354162de304f3850e3789fc87f47213f4daf7fa93443fc6d6ca0ee164374/Macintosh_Programming_Primer_1989.pdf#page=6)

### PDF page 7

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macintosh-programming-primer-1989-ae17ab/1#scan-021e4f8e6035a050ed794e26a2862780355ff19aed0cc7e177f6648e3a4c0e66)

Transcribed text:

vi
The Edit Menu   486
The   Search   Menu
The   Source   Menu
The Windows Menu
489
491
492
Appendix D   The Debugger Command
Summary
The   Source   Window of the Debugger   494
The Data Window of the Debugger   495
Appendix E   Debugging Techniques
Compilation Errors   500
Improving Your Debugging Technique   502
Recommended Reading   503
Appendix F   Building HyperCard XCMDs
The XChooser XCMD   506
Building the XCMD   507
Copying the XCMD into a   Stack   508
Appendix G   Bibliography
Index   523
Contents
493
499
505
521

Languages: English

[Original PDF page 7](https://www.vintageapple.net/files/8422354162de304f3850e3789fc87f47213f4daf7fa93443fc6d6ca0ee164374/Macintosh_Programming_Primer_1989.pdf#page=7)

### PDF page 8

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macintosh-programming-primer-1989-ae17ab/1#scan-611b8e4ad31ea942d7c49bab7182c8abc2f36461aa6af65ad99916a20873c90d)

Transcribed text:

Acknowledgments
WE'D LIKE To thank some of the people who made this book possible:
Deneen Melander and Kate Joyce, who waited patiently for us to
return;
Fred Cole: Without his support and guidance, this book would not have
been written;
Dr.   Oleh   Tretiak, director of Drexel   University's   Image Processing
Center, who gave us the time to do a better job;
Steve   Baker, Bill Wagoner, and Dave Frazier, who covered for us;
Julie Stillman, Debbie Cook,   Perry   Mcintosh,   Judy Ashkenaz,
and David Ershun, who kept this book on track to the end;
Jim Friedlander, our technical referee, who managed to squeeze a
move to Paris in between chapters;
Steve   Chernicoff, who was there at the beginning;
Stu   Mark, who was like a brother to us!
Jacob Joseph Taber. This was why I missed your first birthday party.
Hi, Lori. Hi, Ralph.
Hayward, Mary, Brian, Erik, and Chris, and Amy: the best kind of
kin;
Karen Elizabeth   Ann   Swartz: the newest member of   DATOM
Enterprises;
the great DD: Ross and Chris Bartell, Mike Poreda, Jeff Sesler,
Denis Roark, and   Steve   and Linda Schnetzler;
Erik and Deb Hardy, Missy Kane, and Allen Lang, the folks at NASA
HQ, and the entire gang in LA-thanks, guys!
and finally, our parents, Murray and Trudy Mark, and   Ogden   and
Nancy Reed, who gave us years and years.
vii

Reading notes: Possible OCR spacing artifacts in some lines, such as 'Mcintosh' and 'Chernicoff' Page marker 'vii' at end of text is ambiguous in reading order

Languages: English

[Original PDF page 8](https://www.vintageapple.net/files/8422354162de304f3850e3789fc87f47213f4daf7fa93443fc6d6ca0ee164374/Macintosh_Programming_Primer_1989.pdf#page=8)

### PDF page 9

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macintosh-programming-primer-1989-ae17ab/1#scan-9b0d307b47569bffd4093e1885eca70e22918f7d0c7451177db37adfdf53e888)

Source Code Disk for the Primer

Transcribed text:

viii
Source Code Disk
for the Primer
IF You WoULD like the source code presented in the   Macintosh Programming
Primer   on disk, please send in the coupon on the last page.
In   addition to the source code presented in the book, we also include the
HyperCard   XCMD   source code and libraries. These were made available to
us by Symantec, the publishers of THINK   C.
We hope you like the   Macintosh Programming Primer.   If   you have any
comments or suggestions regarding future editions, you can reach us at this
address:
The Mac Primer-Comments
2534 North Jefferson Street
Arlington,   VA   22207

Reading notes: Possible letter-spacing artifacts in 'Macintosh Programming Primer' and 'THINK C' from extraction

Printed product names: Macintosh Programming Primer · HyperCard · THINK C

Languages: English

[Original PDF page 9](https://www.vintageapple.net/files/8422354162de304f3850e3789fc87f47213f4daf7fa93443fc6d6ca0ee164374/Macintosh_Programming_Primer_1989.pdf#page=9)

### PDF page 10

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macintosh-programming-primer-1989-ae17ab/1#scan-84e73d18b424b25bc301556ffcf595c41ae56669dfdcda468194e70568623865)

Transcribed text:

Foreword
Stephen Chernicoff
EVERYBODY   REMEMBERS   How revolutionary Apple's Macintosh computer was
when it first appeared in January 1984.   One   look was enough to tell you
that this was something new. The bright, lively screen, the high-resolution
graphics, the multiple fonts and type styles-not to mention that funny
little gadget with the button on top and the roller ball on the bottom-all
served notice that this was not just another boring old computer. Here at
last was a machine that met you on   your   terms instead of its own.
Gone were the days of enigmatic prompt characters, cryptic command
sequences, and incomprehensible error messages. In their place was a new
vocabulary of concepts, novel and yet reassuringly natural and intuitive:
windows and scroll bars, pull-down menus and dialog boxes, check boxes
and radio buttons, icons and desk accessories.   Using   a computer was
suddenly easy, comfortable, and above all   fun.   For most of us, it was love
at first sight.
But as great a boon as the Macintosh was to ordinary users, it held an
unprecedented gift for programmers as well. An integral part of   the system
was the   User   Interface Toolbox, a body of tightly engineered, lovingly
handcrafted machine-language code built into every Macintosh in   read-
only memory   (ROM).   By implementing the features of the standard user
interface, the Toolbox gave programmers all the support they needed to
produce finished-quality software with the distinctive Macintosh "look and
feel."
Unfortunately,   even with this considerable helping hand from Apple,
learning to program the Macintosh remained a formidable undertaking. All
ix

Reading notes: Headline not identifiable: the text is a foreword with no distinct primary heading. Source is a foreword excerpt, so the product list is limited to names explicitly mentioned in the copy.

Printed product names: Macintosh · User Interface Toolbox

Printed dates: January 1984

Languages: English

[Original PDF page 10](https://www.vintageapple.net/files/8422354162de304f3850e3789fc87f47213f4daf7fa93443fc6d6ca0ee164374/Macintosh_Programming_Primer_1989.pdf#page=10)

### PDF page 11

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macintosh-programming-primer-1989-ae17ab/1#scan-239520c8c4303502f231fcc1742971efff39bab085bfe309010179d2b00761af)

Transcribed text:

x   Foreword
that increased freedom and convenience for the user imposed a heavier
burden of discipline on the programmer, who had to master a new and
perhaps unfamiliar "event-driven" style of programming. The original
Toolbox included more than   400   different routines, and the latest models
add even more. Apple's own epic reference work on the Toolbox,   Inside
Macintosh,   was a prodigious brainful for any programmer to digest.
It   was to help readers come to terms with this mass of material that I
wrote my   Macintosh Revealed   series of   books back in 1984. My   aim   was to
present the fundamental ideas underlying the Toolbox in a more readable,
accessible way, along with an extensive, fully developed example program
showing how to put those ideas to practical use. I hoped to give my readers
a compass with which to chart their own course through the labyrinth of
Inside   Macintosh.   Still,   the sheer scope of the subject remained daunting.
What was clearly needed was a good introductory book that could serve as
a stepping-stone to the level of   Mac Revealed   andlnside   Mac.
Now, Dave Mark and Cartwright Reed have filled that need with their
Macintosh Programming Primer.   Starting   from the most basic concepts,
they take you by the hand and lead you step by step into the brave new world
of the Toolbox and event-driven programming. Instead of a single, all-
embracing programming example, Dave and Cart have taken a more
gradual approach. A series of   smaller, more manageable programs focus on
specific aspects of the   Toolbox: drawing   simple text and graphics, displaying
and maintaining windows on the screen, defining menu commands,
managing scroll bars and dialog boxes. By the time you've worked through
all the examples, you'll be ready to combine the concepts to build full-scale
application programs of your own.
One   of the great strengths of this book is its emphasis on the use of
resources   as a way of structuring Macintosh programs. The Macintosh
Resource Manager is perhaps its boldest and most innovative contribution
to the state ofthe programming art, an idea whose versatility and power are
only beginning to be fully realized. Right from the start, Dave and Cart
show you how to use resources as a central organizing principle to make
your programming easier, cleaner, and more modular. Their chapter on
Apple's on-screen resource editor, ResEdit, is the best discussion I've seen
on this important program development tool.
If you're interested in learning to program the Macintosh, there isn't a
better place to start than with the book you're holding in your hands right
now.
Stephen Chernicoff
Berkeley, California
December 15, 1988

Reading notes: Possible OCR spacing artifacts in titles such as 'andlnside Mac' and 'Inside   Macintosh' Heading unclear: no explicit primary heading appears in the supplied copy

Printed product names: Macintosh Revealed · Inside Macintosh · Macintosh Programming Primer · ResEdit · Macintosh Resource Manager

Printed dates: 1984 · December 15, 1988

Languages: English

[Original PDF page 11](https://www.vintageapple.net/files/8422354162de304f3850e3789fc87f47213f4daf7fa93443fc6d6ca0ee164374/Macintosh_Programming_Primer_1989.pdf#page=11)

[Next transcribed scans](https://www.vintageapple.net/transcripts/media/va-macintosh-programming-primer-1989-ae17ab/2.md)
