← Basic Microsoft BASIC for the Macintosh

Basic Microsoft BASIC for the Macintosh

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

HAYDEN Macintosh Library FOR THE NEW Version 2.00 Basic Microsoft BASIC for the Macintosh James S. Coan & Louisa Coan

A book cover with a maroon-to-orange gradient background, a surreal framed image of a Macintosh computer with keyboard and mouse on a black-and-white checkered floor under a sky with clouds and arched windows, and cyan wavy lines at the sides.

Reading notes: The 'Version 2.00' text in the red corner banner is rotated and small; its exact line breaks are approximate. The series name 'Macintosh Library' is in a stylized script and may be read with slight variation. Trademark symbols (TM) after Microsoft BASIC and Macintosh are not transcribed explicitly.

Printed product names
Macintosh · Microsoft BASIC
Printed dates
2.00
Languages
English
PDF page 1

HAYDEN Macintosh Library FOR THE NEW Version 2.00 Basic Microsoft BASIC for the Macintosh James S. Coan & Louisa Coan

A surreal illustration shows a beige Macintosh computer with keyboard and mouse standing on a black-and-white checkered floor, framed by open arched windows and clouds in a blue sky beneath a cornice ceiling, set against a maroon-to-orange gradient background with teal wave accents.

Reading notes: The 'FOR THE NEW Version 2.00' text is printed diagonally on a red corner banner and its reading order relative to the title is approximate. The 'HAYDEN' and 'Macintosh Library' wordmark is stylized script; spacing is rendered as printed.

Printed product names
Macintosh · Microsoft BASIC
Languages
English
PDF page 2

050N 104 PRICE 18.95 M 5D 5806

A blank off-white page with a tan, rotated price sticker in the top-left corner bearing small printed codes and a price label, and no advertising artwork or layout.

Reading notes: The sticker is rotated and printed in small type, so the characters '5D' in the last line and the '050N' code could be misread (possibly '050N' or 'O50N' and '5D' or '50'). The 18.95 figure is a shop or price sticker rather than advertised copy, so it is transcribed but not listed as an advertised price. No headline, body copy, or advertised products are visible on this page.

Languages
English
PDF page 3

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

PDF page 4

Basic Microsoft™ BASIC for the Macintosh TM jaIDes S. Coan Louisa Coan [JJ Hayden Book Company A DIVISION OF HAYDEN PUBLISHING COMPANY, INC. HASBROUCK HEIGHTS, NEW JERSEY I BERKELEY, CALIFORNIA \ ....

Reading notes: Author names are partially garbled in the OCR text ("jaIDes S. Coan", "Louisa Coan", "[JJ"). Publisher line and trailing characters are fragmentary.

Languages
English
PDF page 5

Acquisitions Editor: MICHAEL VIOLANO Production Editor: ALBEKD\ BODDY Cover Design: JIM BERNARD Cover Photo: WU ODOR Composition: ART, COPY, & PRINT COMPANY Printed and bound by: COMMAND WEB OFFSET, INC. Library of Congress Cataloging in Publication Data Coan, James S. Basic microsoft BASIC for the Macintosh. Includes index. 1. Macintosh (Computer)-Programming. 2. Basic (Computer program language) I. Coan, Louisa. II. Title. QA76.8.M3C6 1985 001.64'2 85-6837 ISBN 0-8104-6558-2 (pbk.) Copyright © 1985 by Hayden Book Company. All rights reserved. No part of this book may be reprinted, or reproduced, or utilized in any form or by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying and recording, or in any information stor- age and retrieval system, without permission in writing from the Publisher. Microsoft is a registered trademark of Microsoft Corporation. Macintosh is a trademark licensed to Apple Computer, Inc. MacPaint, Mac\Vri.te, QuickDraw, Imagewriter, and FatBits are trademarks of Apple Computer, Inc. Printed in the United States of America 2 3 4 5 6 7 8 9 85 86 87 88 89 90 91 92 93 YEAR

Reading notes: Garbled production credit 'ALBEKD\ BODDY' and 'Mac\Vri.te' may be OCR artifacts. Printed year sequence '85 86 87 88 89 90 91 92 93 YEAR' is a printing-number line, not a single date.

Printed product names
Macintosh · MacPaint · Mac\Vri.te · QuickDraw · Imagewriter · FatBits
Printed dates
1985 · 85-6837 · 85 · 86 · 87 · 88 · 89 · 90 · 91 · 92 · 93
Languages
English
PDF page 6

Preface The material in this book is based on version 2.00 of Microsoft BASIC for the Macintosh. This version is dramatically different from the earlier versions 1.00 and 1.01. Microsoft BASIC, developed by Microsoft Corporation, is in use on vast numbers of computers today. Therefore, if you learn Microsoft BASIC, you will be able to use many computers. In addition, learning BASIC will be a good foundation for programming in other versions of BASIC and other computer languages everywhere. This book is about programming in Microsoft BASIC using a Macintosh computer by Apple Computer, Inc. This BASIC is inter- pretive and highly interactive; that is, we can get at all parts of the program quickly and easily. We can instantly test the programs we write and see results without waiting for some long intermediate process to take place. This interactive nature of BASIC has been a primary reason for its tremendous popularity. We can write pro- grams and instantly command the computer to execute them for us. We can even command the computer to execute individual BASIC statements directly from the keyboard. Our mistakes and typing errors are often pointed out to us in plain English rather than in undecipherable code. This exciting version of BASIC is designed to take advantage of many of the unique features of the Macintosh-from using the mouse to speed program editing to inclusion of very fast and flex- ible graphics. Microsoft BASIC for the Macintosh introduces us to the world of programming in BASIC without line numbers. Instead,

Reading notes: Source text ends mid-sentence at the page break.

Printed product names
Microsoft BASIC · Macintosh
Languages
English
PDF page 7

we may use optional line labels or numbers. Many structures are available to minimize the number of line references required. Even the Macintosh mouse cursor, windows, dialog boxes, buttons, and menus can be controlled by BASIC programs. Problems included at appropriate points in the book make it suitable for the classroom as well as for the individual who wants to learn BASIC. Features of BASIC are generally introduced as they are appropriate for solving a task. Nearly one hundred programs are presented and discussed. The general approach is to begin with small programs to solve real problems and build them up into larger programs as required. One goal is to break programming tasks into segments that can be programmed in a single screen. The list of tasks is organized in such a way that even before we write any BASIC program statements, each item of the list becomes one of the remarks that forms the program documentation. Larger pro- grams are developed by first writing a control routine that will manage a collection of subroutines, and then writing the subrou- tines. Sometimes the subroutines have already been written to solve earlier programming problems. We learn now to use the Command, List, and output windows and get started with simple calculations and printed messages in Chapter 1. Chapter 2 introduces numeric and string variables. Here we also look at modular arithmetic and integer division. The loop concept comes up in Chapter 3, with the formal introduction of FOR and NEXT in Chapter 4. We learn about numeric and string functions, subroutines, and subprograms in Chapter 5. Chapter 6 introduces some of the impressive displays and user interaction possible with windows, buttons, menus, and related features. Chapter 7 presents numeric and string arrays. An alphabet game rounds out the work with string arrays. With many programming concepts and BASIC features in hand, a few interesting applications are considered in Chapter 8: a calendar program, the sieve of Era- tosthenes, and different base numbering systems. Chapter 9 ex- plores the Microsoft BASIC graphics stateinents, with LINE, CIR- CLE, PSET, PRESET, POINT, PUT, and GET. Chapter 10 discusses the famous Macintosh QuickDraw ROM Routines as accessed through Microsoft BASIC. Chapters 11, 12, and 13 take us from a simple se- quential access file to a workable mailing list program. The use of devices as sequential files is discussed in Chapter 11. Appendix A covers use of the Microsoft BASIC menu bar. The keyboard commands for maintaining programs on the disk are presented in Appendix B. A chart of ASCII codes and an example in the Chicago font of codes from 128 to 216 are in Appendix C. Ap-

Reading notes: Hyphenation and line breaks in the body text may affect reading order (e.g., 'pro-gram', 'subrou-tines') Possible OCR error: 'stateinents' may be a misprint of 'statements'

Printed product names
Macintosh · Microsoft BASIC
Languages
English
PDF page 8

pendix D is an alphabetically arranged reference of all Microsoft BASIC functions. A liisting of programs in the text appears in Ap- pendix E. Appendix F contains solution programs for the even- numbered problems. James S. Coan Louisa Coan

Reading notes: Line-break hyphenation in 'liisting' and 'Ap-pendix' may reflect OCR damage Source begins mid-sentence, so the opening context is missing

Printed product names
Microsoft BASIC
Languages
English
PDF page 9

To the Reader

To the Reader Learning to program a computer can be very exhilarating. The thrill of seeing your first apparently complicated idea implement- ed in a clear, simple program is wonderful. People with a diverse range of interests will find that the Macintosh and Microsoft BASIC are especially well suited for learning to program. There is no need to be concerned about any external detail. You can skip operating systems, interfaces, drivers, prompts, PC boards, slots, an~tiost of other things, and get right to the job without having to learn other things. All you need to be able to do is move the mouse to make the little arrow point at the thing you want to do next, press the button on the mouse, and use a typewriter keyboard. The Macintosh and the Imagewriter printer offer an excellent facility to display quality results on paper for permanent records. Everything that the computer does is explainable and predict- able. Take care to evaluate the results that the computer produces. Do not blindly accept computer results as faultless. Under normal conditions, the computer will execute your instructions exactly. That means that mistakes or unexpected program results are usual- ly due to inaccuracy in the program, not to the computer's failure to follow directions. A thorough check of the program almost al- ways turns up a rational explanation for the problem. No one need fear the computer. This is especially true when it comes to learning. When you learn to ride a bicycle or drive a car, someone is bound to notice all your mistakes. This need not be the case with the computer. You can work with it in total privacy and

Reading notes: Garbled OCR span 'an~tiost' in the sentence about skipping operating systems, interfaces, and other things. Source text ends mid-sentence at 'in total privacy and', so the remainder is absent.

Printed product names
Macintosh · Microsoft BASIC · Imagewriter
Languages
English
PDF page 10

your errors are reported to you alone. The computer will keep its secret if you will keep yours. With truly infinite patience, the com- puter never raises its voice or becomes exasperated-not ever. Later, with practice and experience, you may confidently demon- strate your skill in public. Learning to program a computer is not so complicated. You will probably find that an iterative process works best. Read a small section of the book, try it on the computer, and then go back to read some more. There are certain things that you cannot possibly know without being told and some things that just make sense based on what you already know. You will find that reading this book will help with writing the next program, and writing and exe- cuting each program will help with reading the book. A program consists of a set of instructions that causes the com- puter to perform a particular task. The process of writing those in- structions for the computer is called programming. Programs do an amazing variety of things, from the simplest of arithmetic calcu- lations to the most complex of mathematical manipulations. You can write programs to interact with the user. You may want to do this to make the computer play a game or fill out a tax return. You can write a computer program to solve an algebra homework problem, display a graphics design project, or organize a directory of names and addresses. You may even be programming a comput- er just for the fun of it. We hope that you are soon stimulated by your work in pro- gramming to bring to the computer your new and intriguing prob- lems to be solved. Above all, to be successful, you will have to be an active participant. Experiment! Try variations on the programs pre- sented in the text and challenge yourself with the problems. Actu- ally write programs and execute them. Then try to see how what you have learned fits into the picture of the BASIC language and programming in general. While nearly every feature of the language is discussed in this book, you are challenged to fit them together in new ways to work for you.

Reading notes: Source begins mid-sentence, so the opening context is missing. Heading or title not present in the supplied copy.

Languages
English
PDF page 11

Contents Chapter 1 Getting Started 1. 1-1. Our First Instructions 3 1-2. Calculations 1.8 1-3. Using the Printer 22 Chapter 2 Adding Features 25 2-1. More Calculations 25 2-2. Additional Arithmetic Operators 39 2-3. More Messages 42 Chapter 3 writing a Program 49 3-1. Do It Again 49 3-2. Do It Again (When We Don't Know How Many) 60 3-3. Some Handy Tools 70

Reading notes: Page numbers in the table of contents are spaced irregularly in the source copy.

Languages
English