The Apple Personal Computer for Beginners 1982.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
The Apple Personal Computer for Beginners The Apple Personal Computer for Beginners Seamus Dunn and Valerie Morgan (New University of Ulster) Englewood Cliffs, New Jersey London New Delhi Singapore Sydney Tokyo Toronto Wellington / Library of Congress Cataloging in Publication Data Dunn, Seamus, 1939- The Apple personal computer for beginners. Bibliography: p. Includes index. 1. Apple computer. I. Morgan, Valerie, 1943- 11. Title. QA 76.8.A66D86 001.64 82-618 ISBN 0-13-039149-2 AACR2 ISBN 0-13-039131-X {pbk.} British Library Cataloging in Publication Data Dunn, Seamus The Apple personal computer for beginners. 1. Apple computer I. Title II. Morgan, Valerie 001.64'04 QA 76.8.A/ ISBN 0-13-039149-2 ISBN 0-13-039131-X Pbk c 1982 by Prentice-Hall International, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without the prior permis sion of Prentice-Hall International Inc. For permission within the United States contact Prentice-Hall, Inc., Englewood Cliffs, N.J. 07632. PRENTICE-HALL INTERNATIONAL, INC., London PRENTICE-HALL OF AUSTRALIA PTY. LTD., Sydney PRENTICE-HALL CANADA, INC., Toronto PRENTICE-HALL OF INDIA PRIVATE LIMITED, New Delhi PRENTICE-HALL OF JAPAN, INC., Tokyo PRENTICE-HALL OF SOUTHEAST ASIA PTE., LTD., Singapore PRENTICE-HALL, INC., Englewood Cliffs, New Jersey WHITEHALL BOOKS LIMITED, Wellington, New Zealand 109876543 Printed in the United States of America This book is dedicated to the memory of Vincent McGeown colleague and friend --~·:"' Contents Preface xiii I Beginning with Apple I Looking at Apple 1 Communication with Apple 3 First Word 5 Print with Words 7 Special Keys 8 Special Words IO More Communication 11 Strings 12 Problems 14 2 Programming 16 Using BASIC 16 Storing in Memory 17 Changing Line Numbers 18 Input 20 Screen Format 22 Screen Format with Strings 23 Input with a String 24 REM 25 Bytes of Memory 26 Variable Names 27 Problems 27 3 Program Presentation 29 Introduction 29 User Presentation 29 Purpose of Program 30 vii viii CONTENTS Stop 31 List 31 Clear Screen 31 Subroutines 32 Title 33 Reverse Field 33 Flashing Titles 34 Description 34 Spacing 3~ Instruction to User 3 7 Press Any Key 38 Explaining the Answers 39 / Problems 40 4 Disk Management 42 Introduction 42 Diskettes 42 Initializing a Diskette 42 Catalog 43 Program Saving 44 Program Recovery 45 Removing a File 46 Changing File Names 46 Data Saving 4 7 Subprogram 2 47 Subprogram 3 48 Subprogram 4 49 Data Recovery 49 Subprogram 5 49 Subprogram 6 so Program Organization so Subprogram 1 51 Final Points 53 Problems 54 S Graphics SS Introduction S5 Low Resolution 55 Drawing on the Screen S6 A White Screen S8 Colored Screens 59 A Face on the Screen 60 Screen Artist 61 HLIN and VLIN 63 Bar Graphs 64 Color Graph 66 High Resolution Graphics 66 HPLOT and TO 68 Drawing a Circle 69 Colored Circles 72 A Moving Shape 7 3 Problems 76 CONTENTS ix 6 Routines and Useful Information 77 Introduction 77 Left and Right Arrows 77 Screen Editing 78 Stage 1 79 Stage 2 79 The ESC Key 81 Insertion of Missing Words 81 Control Operations 82 Control and C 82 Control and S 83 Control and X 83 Control and G 83 Random Numbers 84 Delays 88 Numbers in Apple 89 Trace/Notrace 91 Problems 93 7 The Use of Machine Code 94 Introduction 94 The Screen RAM 95 Poke 95 Symbol Numbers 95 Screen Numbers 96 Lines and Movement 97 Symbol Listing 99 Screen Number Conversion 99 Random Pictures 100 Introduction to Peek 101 Introduction to Call 104 Music 104 Call and Music 104 Playing a Tune 106 A Machine Code Program 109 Translating machine code 109 An analysis of the program 111 The program in BASIC 113 Poke as a Switch 114 Screen borders 114 Problems 116 8 Strings 117 Introduction 11 7 Definition of Strings 11 7 The VAL Function 118 The LEFTS Function 121 The LEN Function 122 The RIGHTS Function 124 The MIDS Function 125 The CHRS Function 127 CHRS and Quotation Marks 130 x CONTENTS The ASC Function 130 The STRS Function 131 Ordering Strings 132 Problems 13 2 9 Formatting 134 TAB 134 HTAB and VTAB 137 SPC Function 139 Decimal Places 139 Aligning the Decimal Point 143 Extending Decimal Places 145 Using STRS 146 Problems 148 10 A Structured Program ISO Introduction 150 The Problem to be Programmed 151 The Structure 151 The Program 152 Problems 163 11 Apple in the Classroom 164 Introduction 164 Apple as a Games-player 165 Apple as a Calculator 165 Apple as a Teacher 166 Apple as a Manager 168 Apple as an Aid in Simulations 169 Apple for Learning Programming 171 Appendix A Apple Variations and Hardware 172 Introduction 172 Cards and Slots 172 Disk Drives 173 Booting DOS 173 Versions of DOS 174 ITT 2020 175 Bell and Howell 176 Lower-case Letters 176 Appendix B Tape Management 177 Introduction 177 Saving a Program 177 Loading a Program from Tape 178 Appendix C Apple Vocabulary 179 Introduction 179 Words 180 Symbols 192 CONTENTS ~ Appendix D Tables of Peek, Poke and CHRS Numbers 194 Table DI Keyboard Peek and Poke Numbers 194 Table 02 Peek and Poke Numbers 195 Table 03 Peek and Poke Screen Numbers 196 Table 04 CHR$ Numbers 197 Appendix E Other Languages and Software 198 Introduction 198 Integer BASIC 198 Special Integer BASIC Commands 199 Common Facilities 200 Applesoft Words not in Integer BASIC 202 Pascal 202 Why Pascal 202 Using Pascal 203 Pascal and BASIC 203 Other Languages 205 Software 205 Apendix F Base Sixteen Numbers 207 Introduction 207 Base Sixteen 207 Reference Tables 208 Appendix G Answers to Problems 211 Chapter I 211 Chapter 2 212 Chapter 3 214 Chapter 4 217 Chapter 5 220 Chapter 6 223 Chapter 7 224 Chapter 8 230 Chapter 9 235 Chapter 10 240 Appendix H Further Reading 2SO BASIC 250 Apple and General 251 Apple Associations and Journals 252 Index 2S3 Preface This book relies very heavily on learning by doing. It can be used most successfully if the reader is sitting in front of an Apple computer. At all stages it is necessary to test on the machine the ideas and suggestions proposed in the book. Many of the techniques will, in fact, only make sense when they have been typed in and tried. The book is intended for beginners, in the first instance. It is not necessary to have had any experience at all with computers, nor is it necessary to have a teacher available. Anyone who has bought an Apple, or who has access to one, can begin immediately. The pace is deliberately slow and careful, especially in the early chapters, and all the materials have been tried out by a number of beginners. We have not set out to write an introduction to programming or to the language BASIC. Any user of the book will certainly learn quite a lot of BASIC, incidentally; but in order to get the very best possible value from this work, we recommend that an introductory book on BASIC be used for reference purposes, and a list is provided in Appendix H. As well as this the Applesoft BASIC Programming Manual, produced by Apple Computers, is a useful supplementary book and we recommend all readers to use this book as well. There is a mistaken assumption in the minds of many that computers can be successfully used only by mathematicians. We wish to make it clear that, although those with a background in mathematics could learn a great deal about programming on Apple from this book, it was written with a very general readership in mind. In other words those who are worried about mathematics need not be afraid of this book. xiii xiv PREFACE The book is divided into 11 chapters each of which deals with a different Apple facility. New words and new ideas are always introduced with references to an example or series of examples which are meant to be tested at once on the computer. Ideally the book should be read from the beginning, and worked through sequentially since some thought has gone into the ordering of the various ideas. However, a reader with some experience who wished to find information about a specific problem would be able to read the relevant section as a unit in itself. We have written the book about the basic machine and about its general operation and have assumed that the user has a floppy disk system available for off-line storage. We have not referred to printers, or any other peripheral devices, except in appendices. Nor have we attempted to cover machine-code programing in any exhaustive way. We have, however, included a chapter which should make the basic necessities of machine-code programing available to the user. At the back there are reference tables of data showing sets of special numbers associated with Apple. The importance of these is carefully explained in the text. There are also a number of Appendices which list and describe a number of other Apple facilities, including hardware, software, various configurations, Integer BASIC and other languages. We hope that the book will also serve as a reference book for all Apple users, including experienced ones. The index is meant to be com prehensive so that anyone with a query about a particular Apple facility or routine ought to be able to find a suitable explanation or example. We would like to express our thanks to Alex Parke of the Industrial Unit at the New University of Ulster, and Brian Keating of C.E.M.