← Macintosh Programming Using MS-BASIC 2.0

Macintosh Programming Using MS-BASIC 2.0

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™ PROGRAMMING USING MS-BASIC™ 2.0 RICHARD C. VILE, JR.

A red book cover with large silver serif capitals for the title Macintosh Programming Using MS-BASIC 2.0, with the author's name in smaller silver capitals below and a small circular mark near the upper right.

Reading notes: Trademark symbols (™) after MACINTOSH and MS-BASIC are small and rendered as superscript; transcribed as ™. Title lines are large display type; reading order taken top to bottom.

Languages
English
PDF page 1

MACINTOSH™ PROGRAMMING USING MS-BASIC™ 2.0 RICHARD C. VILE, JR.

A red book cover with large silver metallic capital letters reading the title in stacked lines, the word USING in smaller type between lines, and the author's name in smaller silver capitals below, with a dark circular spot near the upper right.

Reading notes: Trademark symbols (™) after MACINTOSH and MS-BASIC and after the 2.0 area are small and reproduced as shown; the superscript placement near the right of the title is approximate. Title is printed in silver foil-like type and may read less crisply in places; text itself is clear.

Languages
English
PDF page 2

No. 2621 $24.95 MACINTOSH™ PROGRAMMING USING MS-BASIC™ 2.0 RICHARD C. VILE, JR. TAB BOOKS Inc. Blue Ridge Summit, PA 17214

A book cover page with large bold black serif title text centered on a cream-colored background, a catalog number and price in the upper right, and the TAB Books Inc. logo and address at the bottom.

Reading notes: Faint ghosted text beneath the title area (apparent bleed-through from the reverse side) is not legible and was not transcribed. Reading order of the upper-right number and price is inferred from layout.

Printed prices
$24.95
Languages
English
PDF page 3

To my parents with love and appreciation. Macintosh is a trademark licensed to Apple Computer, Inc. MacWrite is a trademark of Apple Computer, Inc. MacPaint is a trademark of Apple Computer, Inc. Apple is a registered trademark of Apple Computer, Inc. The Finder is a trademark of Apple Computer, Inc. Microsoft is a registered trademark of Microsoft Corporation. MS is a trademark of Microsoft Corporation. TAB BOOKS Inc offe sale. For informa·t. rs software for I ion and a cat I P ease contact TAB S a og, Department, Blue Ridge o~~~~it _!:A 17294-0850. ' -- FIRST EDITION FIRST PRINTING Copyright © 1985 by TAB BOOKS Inc. Printed in the United States of America Reproduction or publication of the content in any manner, without express permission of the publisher, is prohibited. No liability is assumed with respect to the use of the information herein. Library of Congress Cataloging in Publication Data Vile, Richard C., 1943- Macintosh programming using MS-BASIC 2.0. 1. Macintosh (Computer)-Programming. 2. BASIC (Computer program language) I. Title. QA76.8.M3V55 1985 005.2'65 85-22218 ISBN 0-8306-0321-2 ISBN 0-8306-0221-6 (pbk.) Cover photograph courtesy of Apple Computer, Inc.

Reading notes: The number 85-22218 is a Library of Congress catalog control number rather than a date and may be misread as a year. The source text contains OCR-like line breaks and a partially damaged phrase in the sale notice ("offe", "informa·t. rs"). The reading order of the damaged sale-contact block near the top is uncertain.

Printed product names
Macintosh · MacWrite · MacPaint · Apple · The Finder · Microsoft · MS-BASIC 2.0
Printed dates
1985 · 1943 · 85-22218
Languages
English
PDF page 4

Contents Acknowledgments v Program Titles vi Introduction viii Section 1 Getting Started 1 1 A Tour of MS-BASIC on the Mac 1 2 Programs, Programs, Programs 7 Section 2 Learning the Ropes 11 3 Menu Trainer 11 4 Menu Maze 18 5 Prototype Menu Handler 23 6 Pretty Flashy 29 7 Window Trainer 35 8 Elevator 46 9 Pattern Maker 52 10 Address Book 58

Languages
English
PDF page 5

11 Mouse Utilities 62 12 Quickdraw Trainer 70 13 Scribble and Video 91 14 Rose Patterns 98 15 Ups 'N Downs 112 16 Fancy MOUSE (0) 118 17 Help File Generator 124 18 The Help File Support 128 Section 3 A Programmer's Notebook 132 19 Please Take Note ... 132 20 Macintosh Programming Notes 134 21 Bugs 156 Section 4 Applications 162 22 Cursor Editor 162 23 Mouse Kaleidoscope 180 24 Vocabulary Quiz 204 25 Dialog Designer 219 Section 5 Keeping at It 247 26 Now It's Your Turn 247 27 Challenges Revisited 251 Appendix A Command/Program Cross Reference 257 Appendix B Program Highlights 262 Appendix C Help File Listings 266 Appendix D Feedback 274 Index 275

Reading notes: Source appears to be a table of contents; no headline or advertised products are present Reading order of contents entries should be verified against original

Languages
English
PDF page 6

Acknowledgments I wish to thank Kevin Burton of TAB BOOKS Inc. for his help and guidance during this project. Thanks go to TAB also for giving me the extra time to take full advantage of MS-BASIC 2.0. Tom Steppe of FAME Software gave me the idea for the Pretty Flashy program. Stan Wyszomirski, also of FAME Software, kindly tried out some of my pro- grams and offered valuable suggestions. Finally, to my wife and children, I owe more than I can say. Without their love, patience, and understanding, I never would have started, let, alone finished this project. v

Printed product names
MS-BASIC 2.0
Languages
English
PDF page 7

Program Titles

Program 3-1 Program 4-1 Program 5-1 Program 6-1 Program 7-1 Program 8-1 Program 9-1 Program 10-1 Program 11-1 Program 11-2 Program 11-3 Program 11-4 Program 11-5 Program 12-1 Program 13-1 Program 13-2 Program 14-1 Program 15-1 Program 16-1 Program 17-1 Program 18-1 Program 20-1 Program 22-1 vi Program Titles Menu Trainer Menu Maze Prototype Menu Handler Pretty Flashy Window Trainer Elevator Pattern Maker Address Book Entry Click to Continue Subroutine Crosshairs Flying Crosshairs Mouse Inside Rectangle Subroutine Drag Open a Rectangle Quickdraw Trainer Scribble or Random Neckties Video Rose Patterns Ups 'N Downs Fancy MOUSE (0) Help File Generator Help File Support Windows With One- Pixel Borders Cursor Editor

Reading notes: Program numbering and titles appear in a two-column list; some line breaks may affect reading order

Languages
English
PDF page 8

Program 23-1 Program 24-1 Program 25-1 Program 25-2 Program 25-3 Program 25-4 Program 27-1 Program 27-2 Mouse Kaleidoscope Vocabulary Quiz Dialog Design (Startup Program) Dialog Boxes Generated Basic for Print Setup Generated Basic for Print . . . Changing Cursors Double Click Analyzer vii

Reading notes: Source is a table-of-contents style list of program titles with no advertised products, prices, or dates. Ellipsis in 'Generated Basic for Print . . .' may be truncated text.

Languages
English
PDF page 9

Introduction This book tells you how to write Interactive programs on the Macintosh using Microsoft BASIC 2.0. It assumes that you already know or are rapidly learning BASIC. The em- phasis is on using the interactive features of the Macintosh: menus, graphics, buttons, edit fields, the mouse, and so on. It contains over 20 programs designed to illustrate these topics in as much depth as the thickness of the book will allow. THE ORGANIZATION OF THE BOOK The book is divided into five sections: Section One: Section Two: Section Three Section Four Section Five Getting Started Learning the Ropes A Programmer's Notebook Applications Keeping at It Each section begins with a brief introduction explaining the contents and use of the section. Section One discusses MS-BASIC on the Macintosh and how to use the book. Section Two consists of 16 chapters containing sample programs that demonstrate features and techniques. The emphasis is on the interactive programming features. Each program concentrates on one specific area such as menus, edit fields, or buttons. Each chapter discusses significant points about the program it contains. Section Three is a collection of short discussions of a wide variety of programming viii

Reading notes: Reading order of the section list is ambiguous because section titles are listed separately from their descriptions. Page marker 'viii' at end of text is an isolated fragment and may not belong to the body copy.

Printed product names
Microsoft BASIC 2.0 · MS-BASIC
Languages
English
PDF page 10

topics. First there is a short introductory chapter. The next is a chapter of notes dealing with details of programming interactively. The third and last chapter of the section is a collection of bugs. Each section of the chapter discusses a specific bug. Most of these bugs infested the programs in the book during their development. By studying the bugs chapter, I hope you can avoid some grief. You may also discover how to debug some of your existing programs if you have already started writing programs with MS-BASIC 2.0. Section Four presents four sample application programs partially developed. They are all usable, but none could be considered fully polished. They are complete enough to show you most of what you need to write your own applications. They are incomplete enough to allow you to change them to suit your own style of implementation. Section Five wraps up the book with suggestions about how to continue your applica- tion development career using MS-BASIC 2.0. I have included summaries and cross references of the points illustrated by the programs. This includes a command by com- mand chart. If you want to know which programs use the DIALOG (1) function, simply consult the chart. PROGRAM LISTINGS Each program is listed in full in the chapter that discusses it. I have tried to debug these programs as much as possible. In a few cases, bugs have been left in as challenges. In all such cases, I have indicated how to debug the code. The program listings have many lines that contain a bold, outlined plus sign, + . This is used whenever a long BASIC statement had to be placed on two printed lines. If you enter the programs by hand, you should make sure all such lines are put back together again. Otherwise, the lines will probably cause a syntax error. I will repeat this warning in several places throughout the book, so please bear with me. I would rather bore you with the explanation than have your versions of the programs fail to operate. ix

Reading notes: Several words are split across lines or spaced irregularly, such as 'Section Four' and 'Section Five' and the spacing in 'PROGRAM LISTINGS'. The '+' symbol described in the text as bold and outlined may not render exactly as in print.

Printed product names
MS-BASIC 2.0
Languages
English
PDF page 11

A Tour of MS-BASIC on the Mac

Chapter 1 A Tour of MS-BASIC on the Mac Welcome to the world of Macintosh programming! This book introduces you to MS-BASIC 2.0 on the Macintosh computer. This is a much different language than the microcom- puter BASICs of the past. But then the Macintosh is much different from the microcom- puters of the past. The key to these differences lies in the user interface. I originally entitled this book Interactive Programming because I emphasize Macin- tosh user interface features. MS-BASIC 2.0 has done an admirable job of making the Macin- tosh features available to the "rest of us" as the phrase goes. From MSB 2.0 you can access much of the built-in support for interactive programming: menus, windows, but- tons, edit fields, dialog, the mouse, and Quickdraw graphics. And what is more, you don't have to be an "Inside Macintosh" guru to make it all work! You simply use the packaged commands that MSB 2.0 provides and the rest is automatic. Well, almost automatic. In this chapter, I walk you through some of these capabilities. Along the way, you should get an idea of the kinds of topics that I emphasize in the remainder of the book. If the material here doesn't pique your curiosity, doesn't get your creative juices flowing, doesn't make you want to sit down and start work on your own MS-BASIC applications, then this book is probably not for you. On the other hand, if any of the things I just men- tioned does happen to you, then read on! The fun is just beginning. MENUS In MS-BASIC 2.0 you get a MENU command with several different variations and a MENU function. You can create your own menus and display them on the menu bar. With the MENU ON and ON MENU statements, you can detect when the user has made 1

Reading notes: Repeated OCR-like spacing and hyphenation in body text; product name spelled both MS-BASIC and MSB 2.0 in source

Printed product names
MS-BASIC 2.0 · MS-BASIC · Macintosh · MSB 2.0
Languages
English