← Macintosh Pascal Programming Primer 1990

Macintosh Pascal Programming Primer 1990

From the originals

13 scans

Machine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.

These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.

Image 1

Macintosh Pascal Programming Primer

ddison-Wesley Dave Mark Cartwright Reed Macintosh® Pascal Programming Primer Inside the Toolbox Using THINK Pascal™ Volume I

A book cover with a cream background, blue bold serif title text, and colorful geometric shapes (purple triangle, red circle, green octagon, orange and tan rectangles) behind the individual letters of the word Primer, with gray corner triangles.

Reading notes: The publisher name at top left is cropped, so it appears as 'ddison-Wesley' and is likely 'Addison-Wesley'. The word 'Primer' is set in mixed letter blocks and reads as 'Primer' in reading order. The title 'Macintosh Pascal Programming' is rendered in large display type; the letters are clear.

Printed product names
Macintosh
Languages
English
PDF page 1

Macintosh® Pascal Programming Primer

Addison-Wesley Dave Mark Cartwright Reed Macintosh® Pascal Programming Primer Inside the Toolbox Using THINK Pascal™ Volume I

A book cover with blue bold serif title text on a cream background, large colorful geometric shapes behind the letters of the word 'Primer' in varied colors, and gray triangular corner accents with the publisher name at top left and 'Volume I' at bottom.

Reading notes: The publisher name 'Addison-Wesley' is cropped at the left edge, so only 'ddison-Wesley' is fully visible; the leading letter is cut off. Title 'Macintosh' is followed by a registered trademark symbol ® and 'THINK Pascal' by a trademark symbol ™, transcribed as shown.

Printed product names
Macintosh
Languages
English
PDF page 2

Macintosh® Pascal Programming Primer, Volume I

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

Reading notes: Transcript is intentionally empty per instructions; the exact extracted text is preserved separately. Layout and visual artwork were not verified against the image, only the supplied extracted copy. Headline is inferred from the title block in the supplied copy and may not match the printed hierarchy. Author names (Dave Mark, Cartwright Reed) and publisher imprint lines appear in the supplied copy but were not treated as advertised products. A bullet symbol (•) and a 'TT' mark appear in the supplied copy with unclear meaning. No prices or explicit publication dates appear in the supplied copy.

Printed product names
Macintosh® Pascal · THINK Pascal™
Languages
English
PDF page 3

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 capital letters or all capital letters. Library of Congress Cataloging-in-Publication Data Mark, Dave. Inside the Toolbox using THINK Pascal I Dave Mark, Cartwright Reed. p. cm.-(Macintosh Pascal programming primer; v. 1) Includes bibliographical references and index. ISBN 0-201-57084-X 1. Macintosh (Computer)--Programming. 2. Pascal (Com- puter program language). 3. Macintosh Toolbox (Computer programs). 4. Think Pascal. I. Reed, Cartwright. II. Title. III. Series: Mark, Dave. Macintosh Pascal programming primer; v. 1. QA76.8.M3M3677 1990 005.265-dc20 90-20303 CIP Copyright© 1991 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-MW-91 First printing, December 1990

Reading notes: OCR-style ambiguity in the Library of Congress date string '005.265-dc20' Reading order of catalog data and copyright notice may be mixed

Printed product names
THINK Pascal
Printed dates
1991 · December 1990 · 1990 · 90-20303
Languages
English
PDF page 4

The image is a plain, entirely blank white page with no artwork, layout elements, or markings visible.

PDF page 5

Contents Preface xi Acknowledgments xin 1 Introduction 1 The Macintosh Vision 3 The Macintosh Interface 4 The Macintosh Toolbox 5 Resources 6 About the Book 7 What You Need to Know 8 Why We Chose THINK Pascal 8 Using THINK Pascal 9 Inside THINK Pascal 10 Writing Macintosh Applications 11 Chapter Synopsis 12 How to Use This Book 20 What You Need to Get Started 21 Ready, Set . . . 22 2 Setting Up 23 Installing THINK Pascal 25 Source Code Files 26 ResEdit 27 Macintosh Programming Issues 28 Accessing the Toolbox with Pascal 28 Naming Conventions 29 Predefined Data Types 29 v

Reading notes: OCR spacing irregularities in 'Acknowledgments xin' and 'Ready, Set . . .' lines may reflect damaged characters. Page number 'xin' may be an OCR error for 'xiii'.

Printed product names
THINK Pascal · ResEdit
Languages
English
PDF page 6

vi Macintosh Programming Primer Resources 30 Data Forks and Resource Forks 32 The Hello, World Program 33 Create a New Project 33 The Code 35 Running Hello, World 37 The Problem with Hello, World 39 In Review 39 3 Drawing on the Macintosh 41 Introduction 43 The QuickDraw Coordinate System 43 Window Management 48 Window Parts 48 Window Types 49 Setting Up a Window for Your Application 51 Drawing in Your Window: The QuickDraw Toolbox Routines 54 Setting the Current Window 55 Drawing Lines 55 Drawing Shapes 56 Drawing Text 58 Drawing Pictures 59 About Regions 59 Basic MacProgram Structure 60 The QuickDraw Programs 61 Hello2 61 The Hello2 Project 64 Adding the Resource File 65 Running Hello2 66 Walking Through the Hello2 Code 66 Variants 70 Changing the Font 71 Changing Text Style 72 Changing Text Size 73 Changing the Hello2 Window 74 Mondrian 74 Resources 75 Running Mondrian 77 Walking Through the Mondrian Code 78 Variants 81 ShowPICT 86 Resources 87

Languages
English
PDF page 7

Contents vii Running ShowPICT 90 Walking Through the ShowPICT Code 90 Variants 94 Screen Saver: The Flying Line Program 94 Running Flying Line 98 Walking Through the Flying Line Code 99 In Review 105 4 The Event Mechanism 107 Event Types 110 The Structure of a Mac Program: New and Improved 113 Retrieving Events from the Event Queue 116 Calling GetNextEvent and WaitNextEvent 117 Handling Events 119 Event'futor: The Return of Show PICT 120 Setting Up the Event'futor Project 120 Resources 121 Running Event'futor 129 Walking Through the Event'futor Code 132 Handling mouseDown Events 143 In Review 148 5 Menu Management 149 Menu Components 152 The Pull-Down Menu 154 The Hierarchical Menu 154 The Pop-Up Menu 155 Other Kinds of Menus 156 Putting Menus into Your Programs 157 Timer 157 Setting Up the Project 158 Resources 158 Timer Code 171 Running Timer 178 Walking Through the Timer Code 180 Zinger 191 Walking Through the Zinger Code 197 In Review 203 6 Working with Dialogs 205 How Dialogs Work 209 Modal Dialogs 210 Modeless Dialogs 210

Reading notes: Source is a table of contents excerpt with no advertised products, prices, or dates. Some OCR-like character errors appear, such as 'Event'futor' and 'Show PICT' spacing.

Languages
English
PDF page 8

Macintosh Programming Primer

viii Macintosh Programming Primer The Modal Dialog Algorithm 210 The Modeless Dialog Algorithm 211 Dialog Items: Controls 211 Buttons 212 Checkboxes 212 Radio Buttons 213 Dials 214 Other Dialog Items 215 Working with Alerts 216 The Alert Algorithm 218 Adding Dialogs to Your Programs 218 The Notification Manager 224 Reminder 228 Setting Up the Project 229 Making the Resources for Reminder 229 Setting Up the Notification Manager Resources 234 Adding the Menu Resources 236 The Home Stretch 239 The Reminder Code 240 Running Reminder 252 Walking Through the Reminder Code 255 In Review 273 7 Toolbox Potpourri 275 277 Keeping Track of Windows: WindowMaker WindowMaker Specifications 277 Setting up the WindowMaker Project 278 Running WindowMaker 292 Walking Through the WindowMaker Code The Scrap Manager 306 Scrap Manager Basics 306 InfoScrap 307 UnloadScrap and LoadScrap ZeroScrap 307 PutScrap 308 GetScrap 308 ShowClip 308 ShowClip Specifications 309 Setting Up the ShowClip Project Running ShowClip 315 307 Walking Through the ShowClip Code Inside the Printing and File Managers The Standard File Package 319 309 316 319 294

Reading notes: Table-of-contents page numbers are partially run together and some entries have irregular spacing.

Languages
English
PDF page 9

Contents Using the File Manager Using the Printing Manger PrintPICT 325 322 324 PrintPICT Specifications 325 Setting Up PrintPICT Resources Setting Up the PrintPICT Project Changing the Compilation Order Running PrintPICT 332 326 328 332 Walking Through the PrintPICT Code Scroll Bars! We're Gonna Do Scroll Bars! 334 339 Making Use of Scroll Bars 339 Pager 342 Setting Up the Pager Project 342 Running Pager 350 Walking Through the Pager Code The Sound Manager 358 Sounder 359 Setting Up the Sounder Project Walking Through the Sounder Code In Review 366 8 UsingResEdit 367 Notes on Using ResEdit 371 How ResEdit Works 372 350 359 364 ix Completing a Stand-alone Application: Hello2 Revisited 377 Installing the Finder Resources 379 Examining the Resources of Hello2 380 Adding an Icon to Hello2 381 Rebuilding the Desktop 391 The v e r s Resource 392 Last of the Finder Resources: The s I z E Resource 396 Minimalist, the ResEdit Program 398 In Review 401 9 The Final Chapter 403 Macintosh Periodicals 405 The Essential Inside Macintosh 406 The Typical Inside Mac Chapter 406 Appendixes and Special Sections 407 Apple Technical References 408

Reading notes: Table-of-contents layout makes reading order and page-number associations unclear. Some page numbers are separated from their chapter titles, so mapping is uncertain.

Languages
English
PDF page 10

Macintosh Programming Primer

x Macintosh Programming Primer Macintosh Technical Notes 408 Other Books 409 Apple's Developer Programs 409 Macintosh Developer Technical Support and AppleLink 410 Software Development Tools 411 MPW From Apple 411 Debugging with THINK Pascal, TMON, and Macsbug 412 To Boldly Go 412 Appendix A Glossary 415 Appendix B Code Listings 431 Appendix C Debugging Techniques 493 Appendix D Building Hypercard XCMDs 499 Appendix E Bibliography 507 Index 511

Reading notes: Table of contents page numbers may be OCR-affected; reading order of entries is as supplied

Languages
English
PDF page 11

Preface This book shows you how to write Macintosh applications with THINK Pascal. We wrote it to help people to get down to the business of writing code that displays the distinctive Mac "feel." The Macintosh Pascal Programming Primer evolved from an earlier book that used THINK C to demonstrate the art of Mac programming. That book, Macintosh Programming Primer: Inside the Toolbox Using THINK C, was and is quite successful, and has received favorable reviews from MacUser, Macworld and other computer publications. Many readers sent many helpful suggestions on the C book. A common one was that we write a Pascal version, and here it is. We stress that, although the program designs for these two books are similar, the code has been written from the ground up to take advantage of the THINK Pascal environment. These programs consist of thoroughly tested, debugged, clean Pascal code. We hope that they provide an impetus for you to write your own Pascal Mac applications. If you have THINK Pascal and don't yet own this book, consider InfoWorld magazine's concluding thoughts in a review of Symantec's Pascal package: "an excellent software development environment, with authoritative reference material at a reasonable price. All it needs is a tutorial that explains how to use it with the Macintosh Toolbox ... " ...We give you the Macintosh Pascal Programming Primer. Dave Mark Arlington, VA Cartwright Reed Philadelphia, PA xi

Reading notes: Printed page number 'xi' is the only numeric marking; no explicit publication year is printed in the supplied copy.

Printed product names
THINK Pascal · THINK C · Macintosh Pascal Programming Primer · Macintosh Programming Primer: Inside the Toolbox Using THINK C
Printed dates
xi
Languages
English