Cover image for Mac programming for dummies
Mac programming for dummies
Sydow, Dan Parks.
Personal Author:
Third edition.
Publication Information:
Foster City, CA : IDG Books Worldwide, [1999]

Physical Description:
xxiv, 402 pages : illustrations ; 24 cm + 1 computer laser optical disc (4 3/4 in.).
General Note:
Includes index.
Format :


Call Number
Material Type
Home Location
Item Holds
QA76.8.M3 S92 1999 Adult Non-Fiction Central Closed Stacks
QA76.8.M3 S92 1999 Book and Software Set Central Closed Stacks

On Order



Ten Absolutely Essential Toolbox Functions Inside!

Your Guide to Creating Software for the Mac -- Covers Through OS 8.5 The Mac is back! With the success of the iMac and the power of high-end Macs, new Mac software programs are once again in demand. Whether you're a programming wannabe or a veteran developer, Mac® Programming For Dummies®, 3rd Edition gives you easy-to-understand, up-to-date guidance on Mac programming basics, compilers, programming languages, code writing, and more. So start creating new Mac OS 8.5 applications today -- the fun and easy way! Valuable Bonus CD-ROM Includes:

CodeWarrior Lite -- Limited version of Metrowerks CodeWarrior compiler software ResEdit -- Resource editing software by Apple Computer, Inc. Source code and examples from the book Shareware programs are fully functional, free trial versions of copyrighted programs. If you like particular programs, register with their authors for a nominal fee and receive licenses, enhanced versions, and technical support. Freeware programs are free, copyrighted games, applications, and utilities. You can copy them to as many PCs as you like -- free -- but they have no technical support. System Requirements: Macintosh with PowerPC processor with Mac OS 7.5 Installed; 24MB RAM; CD-ROM drive, double speed (2x) or faster

Inside, find helpful advice on how to:

Compile and run Mac source code easily with CodeWarrior Lite Understand why programming for the iMac is different Create menus that drop and windows that move -- quickly and easily Avoid the most common Mac programming mistakes Become fluent in C, the most important Mac programming language Use ResEdit to edit 'MBAR' and 'WIND' resources Discover Dan Parks Sydow's debugging secrets -- and get your programs up and running faster

Author Notes

Dan Parks Sydow is the author of previous editions of Mac Programming For Dummies as well as Mac OS 8 For Dummies Quick Reference and The Internet For Macs For Dummies Quick Reference. Dan holds a degree in software engineering and has worked on a variety of software projects for Macintosh computers.

Table of Contents

Introductionp. 1
Why Program on the Mac?p. 1
Who Are You?p. 2
What You Needp. 2
What's on the CDp. 3
About This Bookp. 4
How to Use This Bookp. 5
It's Time to Establish Some Conventionsp. 5
How This Book Is Organizedp. 6
Part I Introducing the Macintosh Basicsp. 6
Part II Resources: This Is Programming?p. 6
Part III Using a Compilerp. 7
Part IV Learning the C Languagep. 7
Part V The Moment of Truth: Writing a Program!p. 7
Part VI The Part of Tensp. 7
Part VII Glossary and Appendixesp. 8
Icons Used in This Bookp. 8
What's Next?p. 8
Part I Introducing the Macintosh Basicsp. 9
Chapter 1 Windows, Menus, and a Mouse -- That's the Macp. 11
The Graphical User Interfacep. 11
The Interface Partsp. 13
Working on your deskp. 13
Looking at itty-bitty picturesp. 14
Peeking through windowsp. 14
Using the mousep. 14
Ordering from the menup. 15
Speaking of dialogsp. 16
Wrapping up the interfacep. 17
The Parts You Needp. 18
Menus and windows can do the jobp. 18
So, you think you're getting shortchanged, huh?p. 19
Chapter 2 What Makes Macintosh Programming So Different?p. 21
The Interface -- That's the Differencep. 21
Secret Agents Aren't the Only Ones Using Code!p. 22
Learning the languagep. 23
Different languagesp. 23
All programs were once source codep. 24
Programs Inside and Outsidep. 24
Easier Doesn't Mean Betterp. 26
Mac Programs -- Interesting, Fun, Exciting!p. 27
Giving informationp. 28
Getting informationp. 29
Working with windowsp. 30
Menus mean choicesp. 31
Chapter 3 Using and Programming the iMacp. 33
iMac Featuresp. 33
Processing powerp. 34
More stuff that makes it fastp. 34
Looks nice, sounds nicep. 35
Programming the PowerPCp. 36
Chapter 4 Removing the Fear, Part I: Don't Let Mac Programmers Scare You!p. 37
Demystifying Source Codep. 38
Playing by the rules of the gamep. 39
Decoding some source code terminologyp. 42
Getting a grip on source code organizationp. 42
Eliminating Anxiety Over Saving and Compiling Your Codep. 43
Source code is nothing but textp. 43
Completing the picture with compilingp. 45
Chapter 5 Removing the Fear, Part II: The One-Minute Programp. 49
Remembering Those Conventionsp. 49
That's It? That's a Mac Program?p. 50
Unveiling the programp. 50
Naming the programp. 51
Examining the code, but not too closelyp. 52
Getting it ready, cause here you comep. 52
Opening a windowp. 53
Writing to a windowp. 54
Ending the programp. 55
Ending at the beginning and the endp. 56
That's It ... But Don't Forget the Toolbox!p. 57
Imaging the glory of the Toolboxp. 57
Calling the Toolboxp. 57
Feeling like you're not alonep. 58
Part II Resources: This Is Programming?p. 59
Chapter 6 What Are Resources?p. 61
Defining What Resources Definep. 61
Look, Ma, No Programming!p. 63
Hypothetically speaking about resourcesp. 64
Realistically speaking about resourcesp. 64
The resource/source code connectionp. 65
But How Do You Create a Resource?p. 66
Chapter 7 ResEdit, the Resource Editorp. 67
Editing -- It's Not Just for Text Anymorep. 67
Forget that text!p. 67
ResEdit: one mighty resource editorp. 68
What's in a Name?p. 69
Don't quote me on thisp. 69
A MENU is not a menup. 69
Resource IDsp. 70
Using ResEditp. 71
Creating a resource filep. 71
Discerning the different ResEdit windowsp. 73
Creating your very first resourcep. 75
Adding to a resourcep. 78
Previewing a MENU resourcep. 82
Editing an existing resourcep. 82
Sorry, not nowp. 83
Chapter 8 Two Types of Resources: 'MBAR' and 'WIND'p. 85
Discovering the 'MBAR' Resourcep. 85
Creating an 'MBAR' resourcep. 86
Adding an 'MBAR' to a resource filep. 87
Adding a 'MENU' to an 'MBAR'p. 88
Menus come to order!p. 91
Summing up the 'MENU' and 'MBAR' connectionp. 92
Knowing that 'WIND' Is for Windowp. 93
Opening a resource file ... againp. 94
Breezing through a 'WIND' resourcep. 94
Changing a window's size and locationp. 96
Changing the look of a windowp. 98
Moving onp. 100
Proving that Resources Are Valuable to Source Codep. 101
Part III Using a Compilerp. 103
Chapter 9 Getting to Know You: The CodeWarrior Compilerp. 105
Comparing CodeWarrior Professional and CodeWarrior Litep. 105
Choosing CodeWarriorp. 106
CodeWarrior has everything you needp. 106
Apple isn't the best (for once)p. 107
You can join the CodeWarrior support clubp. 107
Creating a Projectp. 108
Creating a project folderp. 108
Creating a new projectp. 109
Working Togetherp. 113
Launching ResEditp. 114
Creating the new resource filep. 115
Adding a 'WIND' resourcep. 116
Adding a File to a Projectp. 116
Removing a File from a Projectp. 119
Chapter 10 Creating Source Code Isn't Hard, Honest!p. 121
Opening an Existing Projectp. 121
Working with a Source Code Filep. 122
Creating a source code filep. 122
Saving the source code filep. 123
Adding the source code file to the projectp. 125
Reviewing the Creation of a CodeWarrior Projectp. 128
Entering the Source Codep. 129
Opening a source code filep. 129
Typing in the codep. 130
Chapter 11 Compiling and Running Your Source Codep. 131
Compiling Your Codep. 131
What happened?p. 133
Can you type? The compiler lets you knowp. 135
Running and Building Sounds Like Quite a Workout!p. 137
Running Code within CodeWarriorp. 138
Running the codep. 138
Running it again. And again, and againp. 141
Checking Out the New Programp. 142
Part IV Learning the C Languagep. 145
Chapter 12 Choosing C over Other Languagesp. 147
Why Use C on the Mac?p. 147
Everybody's using Cp. 148
Other reasons for using Cp. 148
Those Other Languagesp. 149
Chapter 13 Keeping Track of Things in C: Data Types and Variablesp. 151
Data Types and Variables: Different, but Relatedp. 151
Predetermined C symbols: Data typesp. 152
Do-it-yourself symbols: Variablesp. 152
Every Variable Has a Typep. 154
Every Variable Has a Valuep. 154
Order Is Everythingp. 155
Common Data Typesp. 156
Data types for whole numbersp. 156
A data type for fractional numbersp. 158
Common Variablesp. 159
A Few Examples of Variablesp. 159
Declaring variablesp. 159
Assigning values to variablesp. 160
Chapter 14 Learning the Language -- Just the Basics of Cp. 161
Care to Comment on That?p. 161
Variable Namesp. 162
Operating without a Licensep. 163
Minimal Mathp. 164
The addition operatorp. 164
The subtraction operatorp. 166
The multiplication operatorp. 167
The division operatorp. 167
Operators work togetherp. 168
Operators work with floats, toop. 168
Repeating Yourself by Loopingp. 169
The need to loopp. 169
The while loopp. 170
Changing Directions by Branchingp. 174
The need to branchp. 175
The switch branchp. 176
The if branchp. 179
That's All There Is to C?p. 180
Chapter 15 To Build a Program, You Need a Toolboxp. 181
Why Have a Toolbox?p. 181
Miniprograms by Any Other Namep. 182
The Toolbox Gives and Receivesp. 182
Function parametersp. 182
Functions return valuesp. 184
Sampling the Toolboxp. 186
Chapter 16 Drawing with C: Why Have a Mac If You Can't Draw?p. 189
Quick on the Drawp. 189
The Coordinate Systemp. 190
Let's Draw!p. 193
Drawing a linep. 193
Drawing a rectanglep. 195
Drawing to a Portp. 198
Why have ports?p. 198
WindowPtrs and Portsp. 199
Part V The Moment of Truth: Writing a Program!p. 203
Chapter 17 Examining a Simple Mac Programp. 205
The MyProgram Program Source Codep. 205
Functions Aren't Just for the Toolboxp. 206
Initializing the Toolboxp. 208
Working with a Windowp. 210
Opening a windowp. 210
Writing to a windowp. 210
Planning an addition to the windowp. 211
More planning for the additionp. 213
Solving problems with your boxp. 216
Making MyProgram More Eventfulp. 217
Introducing eventsp. 218
Looking at the MyProgram event loopp. 218
Holding onto an eventp. 220
Improving the MyProgram event loopp. 223
Examining an Even More Eventful Programp. 226
Looking directly into the source codep. 226
Extending a friendly reminderp. 227
Examining the basic stuffp. 227
Examining the event loopp. 228
Chapter 18 Menus That Drop and Windows That Movep. 231
Bringing a Window to Lifep. 232
Dissecting the parts of a windowp. 232
Clicking different parts of a windowp. 233
Working with windows can be a dragp. 235
Closing a windowp. 238
Working windows and breaking out of the loopp. 239
Dropping That Menup. 240
Running through the menu resourcesp. 240
Displaying the menu barp. 242
Pulling down a menup. 243
Making the menu usablep. 245
Handling a menu selectionp. 249
Examining a program with a menu that dropsp. 251
Chapter 19 Writing a Very Mac-Like Program -- Part Ip. 255
Regarding the Animator Programp. 256
Assembling the Folders Needed to Create Animatorp. 257
Starting the CodeWarrior Projectp. 259
Creating Animator's Resource Filep. 260
Creating the resource filep. 261
Adding the Window resourcep. 262
Adding the Menu resourcesp. 264
Adding the resource file to the projectp. 267
Creating Animator's Source Code Filep. 267
Is That It?p. 268
Chapter 20 Writing a Very Mac-Like Program -- Part IIp. 269
Introducing the Animator Source Codep. 269
Viewing the glory of the Animator codep. 270
Knowing What's Going On in the Codep. 273
Finding out about 128p. 273
Declaring variablesp. 274
Initializing the Toolboxp. 275
Displaying menus and windowsp. 276
Establishing the event loopp. 276
Handling a mouseDown eventp. 276
Handling a click in the menu barp. 277
Adding the Beep Me! itemp. 279
Nurturing the Grow Square itemp. 279
Dodging the Move Square itemp. 282
Finishing up with the Quit itemp. 283
Compiling and Running the Animator Programp. 283
Naming the Applicationp. 284
Stating your preferencep. 284
Checking out the new namep. 286
Congratulations!?p. 286
Chapter 21 Where Do You Go from Here?p. 287
Experimentingp. 288
Changing the timing of an animationp. 288
Changing the loopp. 289
More ideas, please!p. 289
Adding the Apple Menup. 289
Understanding why you want to add the Apple to your menup. 290
Understanding Apple menu resourcesp. 291
Dealing with Apple menu source codep. 296
Viewing the AnimatorApple source code listingp. 303
Introducing a More Advanced Program: SightAndSoundp. 303
Understanding what SightAndSound doesp. 304
Pictures and sounds are resourcesp. 305
Workin' with the same ol' kind of projectp. 307
Glancing at the SightAndSound source code listingp. 307
Looking at function prototypesp. 310
Getting another dose of functionsp. 311
That Wasn't Too Bad; How Do I Learn More?p. 313
And Now a Few Words about CodeWarrior Professionalp. 313
Part VI The Part of Tensp. 315
Chapter 22 Ten Steps to Creating a Mac Programp. 317
Creating a CodeWarrior Project Filep. 318
Creating a Resource Filep. 318
Adding the Resource File to Your Projectp. 319
Removing the Resource File Placeholderp. 320
Creating a New Source Code Filep. 320
Saving the Source Code Filep. 321
Adding the Source Code File to the Projectp. 321
Removing the Source Code File Placeholderp. 321
Writing the Source Codep. 322
Compiling the Source Codep. 322
Running the Codep. 322
Chapter 23 Ten Toolbox Functions You Can't Live Withoutp. 323
Using the Toolbox Initialization Functionsp. 323
Displaying a Windowp. 324
Preparing a Window For Drawingp. 324
Displaying a Menu Barp. 325
Capturing Eventsp. 325
Locating a Mouse Clickp. 325
Working with Windowsp. 326
Managing Menusp. 326
Drawing Textp. 327
Drawing Shapesp. 327
Chapter 24 The Ten Most Common Mac Programming Mistakesp. 329
Having Trouble with the Resource Filep. 329
Not Pairing Bracesp. 330
Adding an Extra Semicolonp. 330
Using Incorrect Casep. 331
Forgetting the \p in DrawStringp. 332
Forgetting the and with a Parameterp. 332
Forgetting to Increment a Loop Counterp. 333
Forgetting to Give a Variable an Initial Valuep. 333
Forgetting a Break in a Switch Statementp. 334
Part VII Glossary and Appendixesp. 335
Appendix A C Language Referencep. 337
Variablesp. 337
Declaring a variablep. 337
Giving a variable a namep. 337
Assigning a variable a valuep. 338
Data Typesp. 338
Number typesp. 338
Window typesp. 338
Menu typesp. 339
Operatorsp. 339
Math operatorsp. 339
Comparative operatorsp. 340
Assignment operatorsp. 341
Looping Statementsp. 341
The while statementp. 341
Branching Statementsp. 342
The switch statementp. 342
The if statementp. 343
Toolbox Functionsp. 344
Appendix B Toolbox Referencep. 345
Initializationp. 345
Eventsp. 345
Windowsp. 346
Opening and displaying a windowp. 346
Closing a windowp. 346
Moving a windowp. 347
Responding to the Mouse Buttonp. 347
Menusp. 348
Displaying menus and the menu barp. 348
Responding to a mouse click in the menu barp. 348
Determining which menu item is selectedp. 349
QuickDrawp. 350
Setting up portsp. 350
Moving to a locationp. 350
Drawing a linep. 350
Drawing a shapep. 351
Drawing textp. 352
Appendix C If Something Should Go Wrongp. 353
Errors While Trying to Compile Your Codep. 353
The Compile menu item is dimp. 353
Declaration syntax errorp. 354
Expression syntax errorp. 354
Function call does not match prototype errorp. 355
Cannot convert errorp. 355
Errors While Trying to Run Your Codep. 356
First off, are you in the right section?p. 356
Nothing seems to happenp. 356
A flickering alert and a frozen Macp. 357
The program runs and then quits immediatelyp. 357
Link failed errorp. 358
Errors While Running Your Codep. 358
Things aren't getting drawn in the windowp. 359
A rectangle that should be there just ain't therep. 359
Errors Not Addressed in This Appendixp. 359
Appendix D Glossaryp. 361
Appendix E iMac Programming and Movie Playingp. 365
Playing Moviesp. 365
The Movie Toolboxp. 366
A QuickTime movie-playing examplep. 368
Appendix F What's on the CD-ROM?p. 373
CodeWarrior Professional or CodeWarrior Lite?p. 373
Installing CodeWarrior Litep. 374
Running the installersp. 374
Checking to see if the installation workedp. 377
Installing Other Files from the CD-ROMp. 377
Copying ResEdit to your hard drivep. 377
Copying the ... For Dummies Examples folderp. 378
You're All Setp. 378
Indexp. 379
IDG Books Worldwide End-User License Agreementp. 404
Installation Iinstructionsp. 406
Book Registration Information