Using Macintosh BASIC
From the originals
12 scansMachine-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
Osborne McGraw-Hill using Richard Norling Macintosh™ BASIC
A book cover with a grey background, a blue brushstroke bar beneath the red title, and rows of colorful painted apples with stems and shadows in shifting hues from blue-green to red to green to purple.
Reading notes: The author name and publisher are small and set on the top line, so their exact layout is approximate; the 'using' is a stylized script word.
- Languages
- English
PDF page 1
Osborne McGraw-Hill using Richard Norling Macintosh™ BASIC
A book cover with a grid of colorful crayon-style apples in rows, each casting a shadow, with a blue brushstroke under the red title 'Macintosh BASIC' and a teal script 'using' above.
Reading notes: The publisher name 'Osborne McGraw-Hill' and author name are small and set in a different typeface; the script word 'using' is stylized and read as 'using'.
- Languages
- English
PDF page 2
B177-XXT SOFTWARE SUPERMARKET $17 95
A small rectangular price tag label in the upper left corner of an otherwise blank cream page, showing a black handwritten-style code, a red 'SOFTWARE SUPERMARKET' logo, and a black price.
Reading notes: Price appears as '$17 95' with a space, possibly a decimal point rendered as a space; not certain whether it is $17.95. The label's code 'B177-XXT' and the store name are small and could be misread; the stray mark at the lower left of the label is not transcribed.
- Printed product names
- SOFTWARE SUPERMARKET
- Printed prices
- $17 95
- Languages
- English
PDF page 4
USING MACINTOSH BASIC
Published by Osborne McGraw-Hill 2600 Tenth Street Berkeley, California 94710 For information on translations and book distributors outside of the U.S.A., please write to Osborne McGraw-Hill at the above address. The manuscript for this book was written using MacWrite™ running on 512K Macintosh and a Lisa 2/5 with MacWorks™. Macintosh, MacWrite, MacPaint, Lisa, The Finder, and MacWorks are trademarks of Apple Computer, Inc. Apple is a registered trademark of Apple Computer, Inc. Microsoft is a registered trademark of Microsoft Corp. USING MACINTOSH™ BASIC Copyright © 1985 by McGraw-Hill, Inc. All rights reserved. Printed in the United States of America. Except as permitted under the Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a data base or retrieval system, without the prior written permission of the publisher, with the excep- tion that the program listings may be entered, stored, and executed in a computer system, but they may not be reproduced for publication. 11234567890 DODO 9989765 ISBN 0-07-88157-0 Karen Hanson, Acquisitions Editor Dave Ushijima, Technical Editor Ted Gartner, Copy Editor Nancy Leahong, Text Design Donna Behrens, Composition Yashi Okita, Cover Design Library of Congress Cataloging in Publication Data Norling, Richard, 1943- Using Macintosh BASIC. Includes index. I. Macintosh (Computer)- Programming. 2. Basic (Computer program language) I. Title. QA76.8.M3N67 1985 001.64'2 85-2934 ISBN 0-07-88157-0
Reading notes: Library of Congress catalog line ('001.64'2') includes OCR-like punctuation that may be imperfect Copyright year and ISBN digits in the colophon could be misread in reproduction
- Printed product names
- MacWrite · 512K Macintosh · Lisa 2/5 · MacWorks · MacPaint · Lisa · The Finder · Macintosh · Microsoft
- Printed dates
- 1985 · 1976 · 1943
- Languages
- English
PDF page 5
Contents Introduction Vl Part One Fundamentals of Macintosh BASIC Chapter I Getting Started 1 Chapter 2 Creating Programs 11 Chapter 3 Statements and Operators 21 Chapter 4 Editing Programs 35 Chapter 5 Making Decisions 53 Chapter 6 Organizing Your Program 69 Chapter 7 Using Functions 81 Chapter 8 Manipulating Strings and Text 95 Part Two Intermediate Techniques 111 Chapter 9 Variables, Data, and Arrays 113 Chapter JO Formatting Program Output 137 Chapter 11 Defining Your Own Functions 159 Chapter 12 Using Files 173 Chapter 13 Files, Volumes, and Devices 195 Chapter 14 Using the Interactive Debugger 223 Chapter 15 Advanced Control Structures 233
Reading notes: OCR-style digit 'JO' in 'Chapter JO' may be a misread of '10' Chapter numbers 'I' and '2' appear as OCR-style variants
- Printed product names
- Macintosh BASIC
- Languages
- English
PDF page 6
Part Three Special Macintosh Techniques 247 Chapter 16 Graphics and Shapes 249 Chapter 17 Using the Mouse 269 Chapter 18 Making Music 283 Part Four The Macintosh Toolbox 297 Chapter 19 Using the Macintosh Toolbox 299 Chapter 20 Windows and Menus 313 Chapter 21 Using Controls 331 Chapter 22 QuickDraw Graphics 347 Chapter 23 Using Resources 363 Part Five Programming Style 383 Chapter 24 Professional Polish 385 Appendix A Macintosh BASIC Commands and Functions 393 Appendix B Error Messages and Codes 405 Appendix C ASCII Codes and Keyboard Characters 411 Appendix D Toolbox Routines Accessible From BASIC 417 Appendix E Solutions to Practice Exercises 437 Index 451
- Languages
- English
PDF page 7
Acknowledgments I want to thank all the people who worked on Apple Computer's team to develop the Macintosh BASIC language, without which this book would not have been possible. Three of these people made special contributions. Donn Den- man, the chief creator of the language, was informative, patient, and understanding even when I managed to interrupt his work. Edward Spiegel answered many questions and helped me get all the technical details right as new features were added to the lan- guage. Marianne Hsiung helped me understand several points. Their contributions have made this a better book. RDN
Reading notes: Signature initials 'RDN' at end are not expanded in the source text
- Printed product names
- Macintosh BASIC
- Languages
- English
PDF page 8
Introduction This book is a comprehensive guide to Apple Computer's Macin- tosh BASIC language. It is a complete reference to Macintosh BASIC that progresses from a simple one-line program to compli- cated programs using advanced computer concepts. BASIC is the most widely used programming language on microcomputers because it is the easiest language to learn. Macin- tosh BASIC is even easier to learn and use than the versions of BASIC found on most other machines. It is an interactive language that displays corrective messages as soon as you enter a line that contains an error. The messages are written in normal English instead of computer jargon and are usually clear enough to enable you to correct the error without referring to written documentation. Macintosh BASIC is incrementally compiled, a technique that makes it faster than most other versions of BASIC. Its program- ming environment includes a full-program editor that allows you to use all of the normal Macintosh editing techniques.The built-in interactive debugger is an effective learning and programming tool that is fun to use. A concerted effort has been made to use normal English in this book. Many books about computers use technical terms and com- puter jargon so frequently that it is difficult for the non-expert to understand the concepts being discussed. This book discusses con- cepts in English, using technical terms and jargon only where they add to understanding. vi
- Printed product names
- Macintosh BASIC
- Languages
- English
PDF page 9
HOW TO USE THIS BOOK
HOW TO USE THIS BOOK You do not have to finish reading this book before you write a computer program in Macintosh BASIC. Computer programming is best learned by doing. The most important part of learning to program computers is the experience you gain by actually writing programs. So start using commands in your programs as soon as you read about them. You will learn much more quickly if you do. This book was organized to present the concepts of computer programming and the Macintosh BASIC language in a logical manner, laying the foundation carefully with simple concepts before building up to advanced concepts. If you want to proceed carefully and cautiously, you should start with Chapter 1 and work through the book. The explanations, guidance, help, suggestions, reference infor- mation, and practice exercises in the book are designed both to make your learning experience go smoothly and to serve as refer- ence materials once you have started to write programs. If you are particularly curious about a particular command or subject, feel free to jump ahead and read about it. Just keep in mind that a complete understanding of it may depend on something you skipped earlier in the book. HOW THIS BOOK IS ORGANIZED This book is organized into five parts. Part One, Fundamentals of Macintosh BASIC, contains eight chapters that explain the fun- damentals of Macintosh BASIC. The topics include a description of Macintosh BASIC's windows and menus, operators, program editing techniques, conditional statements, simple control struc- tures, functions, and string manipulations. By the time you finish these chapters, you will be able to write a variety of BASIC programs. The seven chapters in Part Two, Intermediate Techniques, introduce subjects that will help you write more complicated pro- grams. These subjects include defining data arrays, formatting output, defining your own functions, reading and writing data files on disk, using Macintosh BASIC's interactive debugger, and passing parameters to subroutines. Part Three, Special Macintosh Techniques, describes the Macin- vii
Reading notes: Source text ends mid-word at 'Macin-' on page vii, so the Part Three description is truncated.
- Printed product names
- Macintosh BASIC
- Languages
- English
PDF page 10
tosh BASIC commands that let you handle graphics, the mouse, and sound. While many commands are identical or similar from one version of BASIC to another, the commands described in these chapters are unique to Macintosh BASIC because they were specif- ically designed for use with Macintosh hardware. Part Four, The Macintosh Toolbox, describes how to use the routines in the Macintosh toolbox. The features of Macintosh BASIC described in Part Four are not described in the Macintosh BASIC reference manual published by Apple Computer. These undocumented features of Macintosh BASIC allow you to use the Macintosh toolbox routines to handle windows, menus, controls, graphics objects, resources, and assembly language programs. The last part, Programming Style, briefly discusses some of the things involved in polishing your program to professional quality. A NOTE TO EXPERIENCED PROGRAMMERS If you are an experienced programmer, you may be surprised to see what has happened to BASIC. Macintosh BASIC is a structured programming language. It gives you the ability to use either labels or line numbers, and provides new control structures like CASE and DO/LOOP, re-entrant subroutines with parameter passing, and separate programs with parameter passing and local variables. This book teaches structured programming techniques. Stan- dard BASIC GOTO statements are used in Chapter 5 to introduce the concept of flow of control, but appear nowhere else in the book. POP is listed in Appendix A for completeness, but is omit- ted from the text. DISK OF PROGRAMS If you prefer not to type long programs, the programs labeled as Figures in this book are available on a single Macintosh disk. The programs are intended for educational purposes only. For more information about ordering one of these disks, write to: Language Systems Corp. 1217 E Street, S.E. Washington, DC 20003 viii
Reading notes: Opening text is truncated at the start of the excerpt, so the preceding heading or context is unclear. Some copy is in all-caps or spaced letters, which may affect exact spelling of product names.
- Printed product names
- Macintosh BASIC · Macintosh
- Languages
- English
PDF page 11 · PDF page 3
The image is a plain, entirely white blank page with no visible artwork, layout, or markings.
PDF page 12
---cluif-W!--- Getting Started You have a disk that contains Macintosh BASIC and are ready to start programming. But where do you begin? In this chapter you will start by reviewing some elementary concepts. You will learn what a computer program does and will get an overview of how Macintosh BASIC translates programs that you write into a form that the machine can understand. Finally, a quick look at Mac- intosh BASIC's programming environment, including windows and menus, will get you started. PROGRAMS A computer is a collection of electronic parts based on simple yes/no or on/off logic. Included in the computer are a central pro- cessing unit (CPU) and random-access memory, which holds instructions and data while the computer is operating. 1
Reading notes: Leading garbled characters '---cluif-W!---' at start of source may be damaged text
- Languages
- English