Understanding Apple BASIC
From the originals
13 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
UNDERSTANDING APPLE BASIC
UNDERSTANDING APPLE® BASIC Step-by-step Instruction for the Beginner An Alfred Handy Guide FEATURING ORIGINAL PROGRAMS AND EXERCISES by Richard G. Peddicord
A book cover with a cream grid background, a green apple tree bearing red apples above alphabet blocks spelling ALFRED and EDIT, and a gray Alfred Handy Guide logo.
Reading notes: The price on the top-left corner is cut off and partially obscured by a stamp or sticker; it reads as '2.95 U.S.A' with leading characters cropped. The diagonal corner banner text 'FEATURING ORIGINAL PROGRAMS AND EXERCISES' is set on an angle and was transcribed in reading order from the image. Alphabet blocks read ALFRED (top-to-bottom spelling A, L, F, R, E, D) and EDIT on the base; block letters were read as shown.
- Printed product names
- Apple BASIC · Alfred Handy Guide
- Languages
- English
PDF page 1
UNDERSTANDING APPLE®
~ :.9E J.S.A / _/ UNDERSTANDING APPLE® IAlll: Step-by-step Instruction for the Beginner An Alfred Handy Guide E:':] by Richard G. Peddicord
Reading notes: Supplied copy contains garbled or stray fragments ("~", ":.9E", "J.S.A /", "_/", "IAlll:", "E:':]") that could not be confidently read. The headline is inferred from the stacked lines "UNDERSTANDING" and "APPLE®"; the reading order and whether this is the true headline could not be confirmed. "Apple" appears as a title word rather than a clearly advertised product, and the item looks like a book rather than an ad, so productNames may not reflect an advertised product. "Alfred Handy Guide" is partly garbled in the supplied copy ("An Alfred Handy Guide E:':]") and the series name may be inexact. No prices or dates are visible in the supplied copy.
- Printed product names
- Apple
- Languages
- English
PDF page 2
UNDERSTANDING APPLE® BASIC
UNDERSTANDING APPLE® BASIC by Richard G. Peddicord AN ALFRED HANDY GUIDE Computer Series Editor: George Ledin Jr. ~ ALFRED PUBLISHING CO., INC. ~ ~ SHERMAN OAKS, CA 91403
Reading notes: Transcript is intentionally empty because the exact extracted text is preserved separately. Visual layout and artwork are inferred only from the supplied copy and were not verified against the image. The supplied copy is a book title page, not an advertisement, so no advertised products or prices are listed. Line breaks and the ~ symbols in the publisher line are uncertain as to original layout.
- Languages
- English
PDF page 3
This Handy Guide is not a publication of Apple Computer Inc. and should not be used in lieu of the instruction manuals that accompany their products. All information regarding Apple computers may not be accurate or completely up to date. Editorial Supervision: Joseph W. Cellini Cover Design: Paula Bingham Goldstein Copyright © 1983 by Alfred Publishing Co. Inc. Printed in the United States of America All rights reserved. No part of this book shall be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information or retrieval system without written permission of the publisher. Alfred Publishing Co., Inc. 15335 Morrison St. PO Box5964 Sherman Oaks, CA 91413 Library of Congress Cataloging in Publication Data Peddicord, Richard G. Underst.anding Apple BASIC. (An Alfred Handy Guide) Bibliography: p. Includes index. 1. Apple .// (Computer)-Programming. 2. Basic (Computer program language). I. Title. QA76.8.A662P43 1983 001.64'2 83-15654 ISBN 0-88284-246-3
Reading notes: OCR-style spacing artifacts in copyright and catalog lines Garbled catalog entry 'Apple .//' possibly 'Apple II' or similar
- Printed product names
- Apple BASIC · Apple Computer
- Printed dates
- 1983 · 83-15654
- Languages
- English
PDF page 4
CONTENTS 1. INTRODUCTION • • . • • • • • • • • . . . • • • . • • . . . • . . • . • 4 2. ABOUT YOUR APPLE ..•.••.•......•.•....• 5 3. A PRINTING CALCULATOR............... 9 4. LINE NUMBERS AND STATEMENTS • • • 12 5. VARIABLES AND ASSIGNMENT STATEMElfrS •••••••••••••••••••••..•••.•.••• 14 6. INPUTTING DATA FROM THE KEYBOARD • • • • • • • • • • • • • • • • • • • • • • • • • • • • • . • • • • • 16 7. READING DATA FROM YOUR PROGRAM ••••.•••••• ••••••.•••••• •. ••••.. •••• 18 8. A COMPUTERIZED SHOPPING LIST • • • 20 9. ARITHMETIC EXPRESSIONS • • • • • • . • • • • • 22 10. LOGICAL EXPRESSIONS • • . . • . . • • • • • • • • • • • 24 11. IF ••• THEN .~................................ 26 12. FOR • • • NEXT • • • • • • • . . . • . . • . . . . • • • • • • • . • • • • • 28 13. LOAN AMORTIZATION . • • . • . . • • • • • • • . . • • • . . 31 14. MAGIC SUMS • . • • . • • • • • • • • • . . . . • . . • • . . . . . • • • . • 33 15. STRING VARIABLES . • . • . . . . . • . . . . . • . . • • • . • 34 16. ONE-DIMENSIONAL ARRAYS • • • . . . . • • • • . 36 17. ACCOUlfrS RECEIVABLE • . • • • • • • • • . • • • • • 38 18. BUBBLE SORTING . • . • • . . . . • • • • • • . • • • . • . • . • 41 19. TWO-DIMENSIONAL ARRAYS • • • • • • • • • • . . 43 20. LOW-RESOLUTION COLOR GRAPIDCS • • . . . . . . • • . • . • . . . • • • . • . • • • 46 21. HIGH-RESOLUTION COLOR GRAPmcs • • • • • • • • • • • • • • . . . • • • . • • • • • 48 22. SYSTEM AND EDITOR COMMANDS . . . • . 50 23. DISK OPERATION • . • • • • • • • • • • • . • . . . . • . . . • • • 51 24. SEQUENTIAL FILES • • • • • • • • • • . • • • • • • • • . • • • 53 25. WHERE TO GO FROM HERE • • • • • • • • • • • • • 56 26. BIBLIOGRAPHY • • • • . • • • . • • • . . • • • • • • • • • • • • • • 57 27. INDEX • • . . . . . . • . • • • • • • • • . • • • • • • • • • • • • . • . • • • • . • • 58 3
Reading notes: Dotted leaders and OCR-damaged characters (e.g., 'elfrS', 'ACCOUlfrS', 'mcs') make some entries uncertain Page numbers attached to section titles may be misaligned due to OCR spacing
- Printed product names
- Apple
- Languages
- English
PDF page 5
1. INTRODUCTION The Apple II computer continues to be one of the most popular microcomputers of all time. The version of BASIC that has become standard on these machines is called Appleso:ft BASIC, and it is one reason why the Apple is so popular. Appleso:ft BASIC lets you do things that other versions of BASIC do not, such as put many state- ments on the same line, use long variable names, and omit certain parameters. Kids like it because it permits lots of variation, and because it is user-friendly. If you want to learn Applesoft BASIC, this Handy Guide is a good place to start. It is very important that you work the examples on an Apple computer and that you try some of the exercises. Otherwise you may for- get, or never understand, some of the concepts. Many schools and libraries have one or more Apples. Phone around and ask if you can use one. Many computer stores have Apples, and perhaps even some of your friends have them. And of course you can always buy one. The important thing is to be able to use an Apple when you want to. 4
Reading notes: Headline not clearly present; section heading '1. INTRODUCTION' treated as non-primary Printed spelling 'Appleso:ft' appears with embedded colon, preserved as written
- Printed product names
- Apple II · Applesoft BASIC · Apple
- Languages
- English
PDF page 6
2. ABOUT YOUR APPLE A great variety of software and hardware are available for the Apple II computer, and its Applesoft BASIC has become one of the more flexible BASICs in operation today. THE SCREEN The Apple II features a high-resolution color screen of 280 columns and 196 rows, with six different colors (black, white, orange, pink, blue, and green) available for each pi:cel, or picture element. This is about the same resolution and color range as the personal game computers on the market today. It follows that you can program games on your Apple II. It is not possible to attain the same speed as these commercial programs, however, because you will be working in Applesoft BASIC, and the commercial programs are written in assembly language, which is faster because it's closer to the machine language itself. The low-resolution screen on the Apple II has 40 columns and 40 rows, and each pixel can be one of 16 different colors from black to white. The reason why you have more choice of color with the lower resolution has to do with the way the color TV signal is generated and how the color image is stored. HOOKING UP YOUR APPLE The configuration that has proven to be most cost effective and useful consists of an Apple II computer with one disk drive connected to a TV set via an RF modulator. The RF modulator converts the Apple's TV signal into the same kind of signal that the televi- sion receiver is expecting. Most RF modulators for computers generate an output signal that is picked up on Channel 3 or 4. The first thing you must do before turning on the power is to check the connections on your system. Your Apple II computer has a power cord that plugs into the back (see Figure 2.1). Plug this into a grounded 115- volt AC circuit. If you try to use an ungrounded circuit, the manufacturer's warranty is void, and for good reason. Coming out of the Apple will be what looks like a hi-fi cable, and indeed it has the same kind of plug on the end, a so-called RCA phono plug. This plugs into a little metal box that attaches to your TV set antenna, and to your outside TV antenna. There will be a sliding switch on the box that switches power between the computer and the antenna. This arrange- ment permits the family color TV set to be used as your Apple's output device. You may or may not have a disk drive connected to your Apple. If one is connected, so much the better. If one is not connected, do not attempt to connect one using only this Handy Guide. You must use the instruc- tions supplied with the drive. You can, however, hook up your Apple II to a TV set and turn on the power to 5
Reading notes: Extraction includes 'pi:cel' and 'Apple will be' fragments that may reflect OCR or line-break errors Page number '5' appears at the end without surrounding context
- Printed product names
- Apple II · Applesoft BASIC · RF modulator
- Languages
- English
PDF page 7
Figure 2.1 Hooking up your Apple//. both. The Apple's power switch is located in the back on the far left. It is a rocker switch; push the top part in to turn the power on. The power light in the lower left corner of the keyboard will come on. THE KEYBOARD A diagram of the Apple II keyboard is shown in Figure 2.2. Your first step is to try out a few of the essential keys. The RESET key is most useful. Try it. You will hear a bleep from the Apple's speaker and the flashing square cursor will be immediately to the right of the Applesoft prompt character, ] . Whatever pro- gram you were working on will still be in memory, and whatever shapes you had entered will still be there. In other words, no real harm is done if you press RESET. The SHIFT key works the same as in a type- writer: hold it down while you strike a key; the upper- case version of the character will be sent to the central processing unit. In Applesoft, you enter characters one at a time and then press RETURN. Until you press RETURN, the machine has no idea what you have typed in. There- fore you can make all the corrections you want to a line before sending it centrally. The arrow or cursor keys (on the right side of the keyboard) are extremely useful 6
- Printed product names
- Apple// · Apple II · Applesoft
- Languages
- English
PDF page 8
-.l ~ i' t.:> ~ ~ <t> ~ 'E.. <t> ::.::::: ~ C"' 0 ~ Hold down while striking another key. Nothing will appear on screen, but special character will be sent centrally Press for upper case POWER I 48 K I Resets system I Causes repetition of any key held down I Returns to beginning of new line I Moves right past characters I --- Moves left past characters
Reading notes: Key labels and control descriptions are fragmented, with several stray symbols and unclear reading order. The product name 'POWER I 48 K' may be a fragment and its exact spelling is uncertain.
- Printed product names
- POWER
- Languages
- English
PDF page 9
in making corrections, since they move the cursor across text on the screen without changing it. Only when you press another key will the indicated change be made. You will use these keys often. If you want to move the cursor over many char- acters, you can hold down the repeat key (REPT) while you hold down one of the arrow keys. This same REPT key will cause any character to be repeated. Some commands that you should be aware of are listed below: 8 HOME Clears text and moves cursor to top left. DEL Put beginning line number after DEL, then a comma, then the ending line number. Every line from begin to end will be DELeted from program. LIST Lists your program. RUN Runs your program. PR#l Enables printer in slot 1. PR#6 Enables disk drive in slot 6. PR#O Disables printer. EXERCISES 1. Play follow the leader with us. Simply do each thing listed below as many times as indicated: a. Press RESET 3 times b. Press SPACE BAR 2 times c. Press RETURN 1 time d. Press your nose 1 time e. Press letter M 10 times f. Press left arrow(+-) 10 times g. Type PRINT ''GOTCHA'' 1 time h. Press RETURN 10 times
Reading notes: Source appears to be a computer manual excerpt on keyboard commands rather than an advertisement; no headline or product prices present Some characters such as 'PR#O' may be OCR-confused with 'PR#0' and 'LIST' spacing is uncertain
- Languages
- English
PDF page 10
3. A PRINTING CALCULATOR Applesoft BASIC has a feature that is quite use- ful if you have some arithmetic calculations to perform. Basically all you have to do is type the word PRINT I followed by an arithmetic expression that the machine can understand, hit RETURN, and the machine will give you the correct answer. ADDITION AND SUBTRACTION Try this one: PR I NT 5+6 (hit RETURN) 11 You can put several additions or subtractions in one expression. If you don't use parentheses they will be performed from left to right. For example, PRINT 5+6-7-3+ll 5 The machine adds 5 and 6 to get 11, then sub- tracts 7, then subtracts 3, then adds 4. If you put in parentheses, you can change the meaning, as in: PRINT 5+6-<7-3>+4 11 Because the parentheses are there, the machine must subtract the 3 from the 7 before it does anything else. MULTIPLICATION Multiplication is indicated by the asterisk *, as in PRINT "13 TIMES 14 IS "13*14 13 TIMES lll IS 182 Notice that if you put a message in quotes it will print exactly what you wrote. This allows you to iden- tify what the numbers are. If you need to multiply a sum of items by a given number, as in a sales tax calculation, you would use parentheses: PRINT Cl.26+0.23+4.99>*0•6 .3888 DIVISION Division is indicated with the slash sign (!). As with multiplication, if you want to divide a sum of num- bers by a certain number, be sure to put all the terms of the sum within parentheses. This forces the machine 9
Reading notes: OCR spacing and character errors in several places (e.g., 'PR I NT', 'll' for 11, 'Cl.26' and '!' for slash). Reading order of the final division paragraph is cut off at the source boundary.
- Languages
- English
PDF page 11
to add them together before it divides. Say you want the average of 5, 43, and 67. This will give it to you: PRINT "AVERAGE IS ";(5+43+67)/3 AVERAGE IS 38.3333333 If you have an expression with only multiplication and division, the operations will be performed from left to right. Thus: PRINT 1/2*3 1. 5 But: PRINT 1/(2*3> .166666667 We say that multiplication and division are on the same level of the arithmetic hierarchy. A string of mixed multiplications and divisions will be performed from left to right unless parentheses make it otherwise. Multiplication and division take precedence over addi- tion and subtraction. This means that they will be done first. For example, PRINT 3+2*6 15 If addition took precedence over multiplication it would add, then multiply, as in: PRINT <3+2>*6 30 EXPONENTIATION The last arithmetic operation is exponentiation, the power operation. Recall that "a to the power b" means a muliplied by itself b times. On the Apple key- board the hat symbol (/\)means exponentiation. Thus: PRINT 3/\2 9 AND PRINT 2/\3 8 Exponentiation is at the top of the hierarchy, in that it will be done before multiplication and division. A string of exponentiations will be done from left to right. IO EXERCISES 1. Perform the following arithmetic calculations using a print statement: a. 457 + 32 + 94 b. 34 times 237
Reading notes: Source appears to be a BASIC programming manual page with OCR-style spacing artifacts; some characters such as '<' and '>' may be misread parentheses, and '/\' is the exponent symbol.
- Languages
- English