Table Of Content- .
THE MACINTOSH PERFORMANCE LIBRARY
Danny Goodman's
HyperCard
Developer's Guide
Danny Goodman's
HyperCard
Developer's Guide
Danny Goodman
BANTAM BOOKS
IDRONTO • NEW YORK • LONDON • SYDNEY • AUCKLAND
Danny Goodman's HyperCard Det1eloper's Guide
A Bantam Book/July 1988
All Rights Reseroed
Copyright © 1988 by Danny Goodman
Cot1er design © 1988 by Bantam Books, Inc.
Interior design by Nancy Sugihara
Produced by Micro Text Productions, Inc.
This book may not be reproduced in whole or in part, by mimeograph or any
other means, without permission. For information address: Bantam Books, Inc.
Apple, Image Writer, Laser Writer, and MacPaint are registered trademarks of Apple
Computer, Inc.
Finder, HyperCard, HyperTalk, Macintosh, MultiFinder, and StackWare are trademarks
of Apple Computer, Inc.
APDA is a trademark of A.P.P.L.E. Co-op.
Turbo Pascal is a trademark of Borland International.
DiskT op is a trademark of C.E. Software.
MacRecorder, HyperSound and SoundEdit are trademarks of Farallon Computing, Inc.
SoundWat1e is a trademark of Impulse, Inc.
Stack Exchange is a trademark of Heizer Software.
Icon Factory is a trademark of HyperPress Publishing Corp.
Video Works is a trademark of Macromind, Inc.
Visual Interactive Programming is a trademark of Mainstay.
HyperDA is a trademark of Symmetry Corp.
LightSpeed C and Light Speed Pascal are trademarks of Think Technologies.
VideoStack is a trademark of The Voyager Company.
NOTE
BANTAM AND THE AUTHOR SPECIACALL Y DISCLAIM ALL WARRANTIES,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WAR
RANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PUR
POSE WITH RESPECT TO DEFECTS IN THE PROGRAM LISTINGS IN THE
BOOK, AND/OR THE TECHNIQUES DESCRIBED IN THE BOOK, AND IN NO
EVENT SHALL BANTAM OR THE AUTHOR BE LIABLE FOR ANY LOSS OF
PROAT OR ANY OTHER COMMERCIAL DAMAGE, INCLUDING BUT NOT
LIMITED TO SPECIAL, INODENT AL, CONSEQUENTIAL OR OTHER DAM
AGES.
ISBN 0-553-34576-1
Published simultaneously in the United States and Canada
Bantam Books arc published by Bantam Books, Inc. Its
trademark. consisting of the words •sant am Books" and
the portrayal ofa rooster, Is registered In US. Patent and
Trademark Office and In other countries. Marca Regis
trada. Bantam Books, Inc. 666 Flfth Avenue, New York.
New York 101m
PRINTED IN THE UNITED STATES OF AMERICA
0 9 8 7 6 5 4 3
Contents
Acknowledgments xi
A Note to My Friends xili
Introduction. When Is HyperCard the Right Choice? 1
A Range of Developers • "Developer'' Defined • Stack Categories • Infor
mation Publishing • Information Management • External Device Control •
Utility Stacks • Other Than HyperCard • Flat File Databases • Relational
Databases • Relational Basics • H ypetCard vs. Relational Databases •
Database or HyperCard? • Traditional Programming Environments • The
• · Final Choice • The Next Step
PART ONE
Key Stack Developer Issues
1 Issue 1: How HyperCard Literate is the User? 27
Difficult Concepts • Installation Routines • Pathname Settings • Inside the
Stack Button • Hands Off the Home Stack • User-Friendly Front Ends •
Printing Cards • Script-Writing Scripts • Customization Front End • Front
End Visuals • The Watch Cursor • Anticipating Macintosh Literacy
2 Issue 2: Designing for all Macintosh Models 47
Execution Speed Concerns • Macintosh Plus • Macintosh SE • Macintosh
ll • What About Floppies? • Multimegabytes of RAM • Screen and Card
Size • Screens and Menus • Timing • Ticks, Seconds and Delays • When
Delays Are Necessary • Animation
3 Issue 3: What About the Macintosh User Interface? 59
The Menubar • Inapplicable Menus • When to Show Menus • Buttons,
Icons, and Clicking • Of Mice and Clicks • Single Clicks Do All • Trapping
Double Qicks • Icon Buttons • Button Feedback • When to Highlight •
vi HYPERCARD DEVELOPER'S GUIDE
Radio and CheckBox Button Highlighting • Feedback Problem • Choose
the Correct Button Style • Taking a Stand
4 Issue 4: Screen Aesthetics 75
My 80/20 Aesthetics Rule • Macintosh Artists and Screen Artists • Icon
Design • Finding an Artist • Paying for Art • Working With the Artist •
When to Hire the Artist • Key Design Guidelines
5 Issue 5: Stack Structure 89
Internal and External Structures • Homogeneous and Heterogeneous
Stacks • Navigation Flow • The Straight Line • The Tree Structure • The
Cobweb • Hybrid Structures • Stack Systems and Non-linearity • Decid
ing Stack Structure • Heterogeneous Stack Advantages • External Struc
ture • Floppy Disk Concerns • Focal Point Strategy • Business Class
Strategy • CD-ROM Structure
6 Issue 6: Converting Existing Databases to HyperCard 113
Is HyperCard the Right Environment? • Field Structure • Replicating
Narrow Sorts • To Combine or Not To Combine Fields • Multiple-Lined
Fields • A Case for Single Fields • Field Design Tricks • Importing Data
base Data • Preparing the Data • The Script • Changing the Field Struc
ture • Importing Word Processing Data • Handling Long Text Blocks •
Long Text Import Scripts
7 Issue 7: Stack Protection 133
Why Protect? • Private Access Protection • Stack Delete Protection • Can't
Modify Stack Protection • User Level Protection • Protection Problem •
When to Lock the User Level • When NOT to Lock the User Level • Com
mercial Proprietary Secrets • True Protection • Buying and ·"Borrowing''
XCMDs
8 Issue 8: Engaging the Couch Potato 145
Make Stacks Inviting • Articles of Engagement • Present an Opening
Screen or Sequence • Use Visual Effects Wisely • Make Buttons Look Like
Buttons • Use the Appropriate Structure • Transform Data Entry Into
Mouse Clicks • Build Magic Into the Application
9 Issue 9: Making Stacks Customizable 155
Leaving Oues • Customizing Front Ends • Building and Extending Dated
Contents vii
Stacks • Customizing User Preferences • Inside the Preferences Card •
Button Customization • Inside the Button Customization
10 Issue 10: Stackware is Software 167
Software Design • A Functional Specification • Prototypical Focal Point •
Provide On-Line Help • Help In Context • Introduction and Stack Over
view • Intercepting Help • Include a Good Manual • Who Reads It? •
Who Should Write It? • When to Write It • How Should It Look? • Pro
vide Data Importing • Test, Test, Test • Start Testing Early • Testing
Procedures • Be Smart About Marketing • The Retail Channel • Low-Cost
Publishing • Self-Publishing • Open Channels • Choosing the Channel
11 How to Build a Stack 187
Different Methods • Information Publishing Stacks • Information Manage
ment Stacks • External Device Control Stacks • How to Go Wrong
PART TWO
HyperTalk Techniques for Developers
12 A Different Approach to HyperTalk 201
A Working Laboratory
13 Scripts and the Object Hierarchy 209
The Hierarchy-Two Perspectives • Making the Chapter's Stack • The
Target and Me • Short, Medium, and Long Target Names • Target Deci
sions • Naming Objects and Target Names • When to Use the Target • The
Target and Me • Choosing the Appropriate Level • Reducing Handlers •
The Ultimate Handler Reduction • One Handler Fits All • CloseField
Handlers • Lateral Hierarchy • Stack-to-Stack Hierarchy • Background-to
background hierarchy • Bypassing the Hierarchy
14 More About System Messages 243
Who Gets Which Message • Mouse Messages • Press-and-Hold Buttons •
Remote Control of Buttons • Field Messages • A "Field" Experiment • To
Oose or Not to Close • Taxing Returns • Open and Close Object Messages
• Keyboard Messages • Keyboard Trapping in Fields • Field Entry Valida
tion • The Text Arrows Property • ArrowK ey Messages • The ControlKey
viii HYPERCARD DEVELOPER'S GUIDE
• Function Keys • DoMenu • Suspend and Resume • StartUp and Quit •
Help • Idle • Idle in Business Class • Idle in Focal Point • Controlling
Navigation • Button Navigation • Arrow Key Navigation • Menu Naviga
tion • Message Box Navigation
15 Sending Your Own Messages 275
Commands and Messages • Why a Custom Handler? • Stack Commands
• Convenience Handlers • Naming Your Messages • Modifying Hyper
Talk Commands • Passing Parameters • Passing Multiple Parameters •
Parameter Variables and the Param Function • Parameters and Global
Variables
16 User-Defined Functions 293
What User-Defined Functions Do • Functions and the Hierarchy • Func
tion Syntax • Returned Values • Function Modularity • Simple Functions
• Passing Parameters • Multiple Parameters • Using Your Function Li
brary
17 Diving Deeper Into Control Structures 303
Control Basics • If-Then-Else Constructions • If-Then-Else Style • If-Then
Else Reduction • Repeat Basics • Repeat With Constructions • Looping
Through Object Names • Naming Sequential Objects • Number Formats
and Object Names • Nested Loops • Repeat Forever • Repeat Performance
18 Setting Up Linked Cards 325
Suite Examples • Multiple-Lined Containers-Arrays • More About
Arrays • Type A Suites: Hub and Spokes • Type B Suites: Rolling Hub and
Spokes • Linking on the Fly • Type C Suites: The Accordion • Adding and
Deleting From the Accordion Suite
19 Working With Date and Time 351
HyperTalkFunctionsandCommands • Seconds-The Common Thread •
Adding Time • Times Include Dates • The Handler • World Time Conver
sion • Foreign Daylight Saving Time • Elapsed Time Counter • Days
Between Two Dates • Dates Before Deadlines • International Dates
20 Solving Searching and Sorting Mysteries 373
Workbook Stack • Entering Sample Data • Simple Finding • Finding By
Field • Find in Field Workaround • Boolean Finds • Find Whole and Find
Contents ix
String • Plain Sorting • Sorting By Field • "Dual Key" Sorts • Sorting Card
Suites
21 Authoring and Debugging Tools 385
Home Stack Tools • Author Tool Shortcuts • Using Scripts to Build Stacks
• Debugging • Check the Script Editor • Heed the Error Dialogs • Tracing
Variable Values • Testing If-Then Constructions
22 HyperTalk Script Style and Practice 401
Practice and Style Guidelines • Readability • The Preamble • Line Spacing
• Command Lines • Efficiency • Timing Tests • Comprehension
PART THREE
Resources For Stack Developers
23 A Resource Crash Course 413
The Resource Concept • Macintosh Files-Data and Resources • Anatomy
of a Resource • HyperCard Resources • Resources and the Hierarchy •
Resource Tools • Using ResEdit • ResCopy
24 Icon Resources 429
Icon Basics • Creating an Icon Resource • Preparations • Applying the Art
• Make a New Resource • Commercial Tools • Extracting Icons
25 Sound Resources 447
Why Sounds? • Using Sound in a Program • Digitized Sound • Macintosh
Sound Resources • Converting Existing Sounds • HyperSound • Produc
ing Sound Stacks
26 Introduction to XCMD and XFCN Resources 455
What is an XCMD? • Why XCMDs? • Writing Your Own XCMDs • Learn
ing Library • Before You Go Off to Learn a Language • In Case You Know
a Little Pascal • Calling an XCMD-What Happens • What You Need to
Compile XCMDs • What APDA Sends You • Calling an XCMD-Object
Hierarchy • About the Following XCMDs
x HYPERCARD DEVELOPER'S GUIDE
27 An About Box XCMD 469
The Stack • Calling Conventions • Design Assumptions • The XCMD •
How the XCMD Works • Error Handling • Creating the DLOG Resource •
Further Ideas
28 A Pop-Up Menu XFCN 497
The Pop-Up Menu Interface • Pop-Ups and HyperCard • The Stack •
Calling Conventions • Getting Items in the Menus • What the XFCN
Returns • Design Assumptions • The XFCN Project • How the XFCN
Works • Creating the MENU Resource
29 A Serial Port XCMD 523
What Comm Can Do • The Stack • Calling Conventions • Opening and
Closing Serial Ports • Writing and Reading • Connecting to a Service •
The Communications Session • Dialing and Logging On • Getting the
Weather • Logging Off • How the XCMD Works • Further Ideas
30 A Final Word 553
Appendix A. Sources 555
Appendix B. Interactive Sound in HyperCard by Tim Oren 559
Appendix C. Writing XCMDs in LightSpeed Pascal 581
Appendix D. Writing XCMDs in LightSpeed C 597
Appendix E. Writing XCMDs in Turbo Pascal 619
Appendix F. Writing XCMDs in Mainstay V.I.P. 627
Index 635