You are on page 1of 93

ASIC PROGRAM

ING REFERENC

MANUA

~BL OF CO
If many fsultes in tllis book you fynde. Yet th i ttl< not the "0' r ac ton blyttde; If Argos hee •• hymselfe had beene lie should pe [chance no t .,11 have seene , Richard Shacklock ••• 1565

s
CHAPTER

XII

OVERVIEW

GEn. GSTARTED
l~dlnLe-Executlon Ih,rerred-[xecution CD~mands COllDllilnds Ex mple

~
S J 9

Number

Format

Culer Craphics I'r Int Forma V. rlllbl., 'a If" ... TRW

I~ Anether Color Ex mpl. II FIt. .. m:XT
14 /IndY

I
11

COSUB ...REt~N
R!'.AD•.• DATA •.• REStORE

Published by APPLE COMPUTER INC.

R~ 1, Tnte~er nnd String Variables Slrln!l-s 21 Hac" Color CrnphiC:9 2~ H[gh-~e.oluLlDn Color GTnph1<s
Irl 95\114

I@

1~26P Banrlley Drive
Cupertino. California

(408) 996-l(WI

All rights reserved. No part of this publication lnIIy be reproduced without the prior written permission of APPLE COMPUTER LNC. Plesse call (4118) 996-11110 for more infor .... tion.
01978 by APPLE COMPUTER INC. Reorder APPLE ProductM2LIJ0il6

(0311-11\113-113)

kyb 423 B2 9126

CHAPTER DEFINITI:ONS
3~ Syntactic O"finition" "nd Ahl>re"intlons

2
SYSTE
)11 I.oAIl NUi ,.,d SAVE

CHAPTER

3

36 36
36

Rules fcr tvaluating Expressions Conver.lcn of Types Execution odes

IIIlN
OJ

.\1 •
I

8101'. f:ND. ctrl C, IIlACI: nd OrnACE

reset

and

cmrr

I'f I K

t,l,

.~

I'Q'!: WAr1 All. IIIHEM: I (llF~'1: USR

II

III

CHAPT·R COMMANDS
_S :>Q LIST REM VTAII HTAlI TAll POS SPC HOME CUAR FltE ,LASH. lIIVERSE and !401U1AL SPEED @sc A. He 8, esc C nnd es~ D rel'c [

CHAPTE

5

EDITI GAD

FORMAT-RELATED

In Chapter J, also Hee crrl C. .9 DEL SO
50 51 Sl 52 52
)2

53
5)

54 54 55

5, 55

right nrrow and Lef r arrow

et r I X

IV

v

CHAPTE,R
I p'U r IOUTP'UT COMMANDS
In Chapte~ In Chap<er J, a150 see LQAD and SAVF.; 5, see STORE and RECALL.

7

COMMANDS RELATING TO FLOW o CO TRO
l'
I" 1 11) I'.

66
7

JllPUT

.oro
'1' ••• rHr ' and IF ••• GOTO fall.. ., II ••• stEP ;~ XI GllSUB RlllJn 1'11' o~ •.. r.uTO and 011... GOSUS
ON1:RR COTD

&8 DATA 69 READ
7(1 71 72 72

GET

RESTORE
PKI,rr LN' 1'1\1

7f1

8",
Kif 81 111 6

n

LET
IlEF I'M

III SUi'll.

VI

vu

CHAPTER GRA Hies AND GAME C
84 TEll. 1.ow Resolution GR COLOR IILUi Graphics 84 85 8

CHAPTER

9

TROLS

HI H-RESOLUTON
Table

SHAPES

85 PLOT
86
Bl

VLIH
Sl.l~1'I

Hlgh-resolutj"n Graphics
HG HGII2 eg KCOLOR 811 HPWT Ga.... Controls 87 88

911 PDt

VIII

IX

10
11,J2 The built-In funclions SIN, COS, TAt!, ATll, HIT, RND, SGM, .Y!S, SQR, I'.XP, LOG

APPENDICES
API' ndlx 111'1' lI"tx II ~ ApI" n,H. I III ndl" lJII 111'1" x ndl 11.1;' 1111 A:
8: Gettins APPLESOfT BASIC up

"I'~'

C:
(),

E::

t03

Derived

Functions

III 1~ J~4 Ir I II

11ft I,ll
1, I,

'\I'I'~n<ll" API" "db. "l't" I"dlx Arp~'ndl'K "1'1',."dl" A~p, "dl x

c:
H:

r:

Proll'"'" F.diti n!', iJ;rror i'lessages Spa"" Savers Speed1ng Up Your Progr~m Deci~l Tokens for Keywords Reserv<ld 110 rd~ in API'LE50FT
C<>,,""rr Ins: lIAS l C Progt' .. ",,,
Lo

APPLESOFT

1: J: K, II:

M.<!moryM.o p

(9""",1 so pOll" lJ 7)

1pp"nd1x Append1x
II PI', ndb. It.I'P<'ndh

L:

N:
0,

Differences
Alphabetic s,u_ry

PEEKs, POKE,. Gnd C':I1.L8 A.SCH ChAra<'te' CadI'S ~PL£SOFi ~erc Fage Usage

I ,V

and Abbr~vj.[ions

Bet~ecn APPL~SOFT and Integ.r BAS[C Glossary of Synl.c~t< Definitions
CClilIlMnds

of ArnESOIT

If>

llUlCl(

IF~side Bacl Cover: .... 1phab" Li .. "d Index of APPLESOFl CO"""",ltl ..

x

XI

OVERVIEW
INTRODUCTION
APPLESOPT 11 BASIC is APPLE's very much extended BASIC language. BASIC has be"o ext""d"d because there are many features on the APPLE LI computer that .lU.9t aren't available on other compute.rs that use BASIC,. Jly.dding .. fe ... new words to the BASIC language, these features are illlllledilltely available to anyone using APPLESOPT. Among the features supported by APP.LESOF't are APPLE's color graphics, high-resolution color graph1cs and the direct analog inputs (the same controllers). Aoocher feature of APPLESOFT 1s this manual. It is not II self-te . ,ching manua l., since APPLE provides " separate manual (the APPLE !l BASIC Programming Manual) which will help you learn to program even if you have never touched a compute .r before. This manual assumes that you know how to program in BASIC and just wish to learn the additional features offered by APP~ESOFT. Chapter 1 (GETTINC STARTED) is a quick ~un-throug~ of whst the laue"age has to of fer. The rea t of the manulll is a careful and axa C t description of every st3t"ment in the language and how each statement works. To help save you the frustratioo and annoyance that some manuals can cause. thia manual points out places where programming errors csn cause you difficulty. Special symbols call your attention ."these points. The method used to describe APrLESOFT is almost a simple language in itself. You will f1.nd that, after II fe", momeau. ge t t.Lng used to it, it wl11 speed your underStanding of e""ctly what 16 legal and illegal in the language. You will not be left with any nagging doubts about the interpretation of a sentence, as can happen with pure English descriptions. Advanced programmers "ill find this manual especially helpfuL Bagton'ing programmers are reminded that they will soon no longer be beginners, and will appreciate the ,,"t'!"a effort APPLE has made to provide an unuBu.ally compler .. manual. To be. sure, a thicker manual looks more formidable, but ",hen you nead the information, you will be glad that we took the time and space to put it in.

two tct"ms you'll need to know when reading this manual. The "'ord ref ra 0 the structure of a computer command, the order and jlUI)JWI l(rna. the command"'s v,£Itlaus pares. The word "parse" ["e..fers to the "MY III ullt h th computer attempts to interpret what you type, picking out I h' v"rluus I>orcs of the computer commands 1n order to execuee them. Po r "11""'" 10·, APPI,ESOn" a syn tax 1ll1a"'" you to rype I/K~-I.~J"'2 IIh "'1'1'1.1:501''1' parse" this lnpu~, it: first picks out 12 as the program line 11 ,1>, r , h n 1n acp"Cecs X5 as an arithm.,tic variable name. Finally. AI'I'I ••.!l1l1'T ov lUGte" 3-2 as 9, then multip1ie.9 by 4, and assigns ·the value 36 ~.J I h .. un r tnb Ju whose name is 1(5.

""y,,'41)'"

II"

I,,,

or

n""., "r
I."VI'

I provides

h .. d 11 t1 experience I ut I ",hl ed '. u81ng examples

II I v .. , II ..

nil I"

u TH

an overview of many APPLESOFT commands, for chose who prograJllllling in BASIC. Many primary concepts are tlla t you can eype in to the COmputer. Appenddx B on editing APl'LESOFT prog"rsl:l9.

Introduced at the beginning of Chapter 2 1s used to describe conc.i.selyand unambiguous.ly. I t will aava you time and " [r111 I .. undl.'tHtanding how the commands must be at ruccur ed , You don't need ,h" I.hb notation yourself, but it will help you answer many questions II"! "I"W 111. oJly dhcus".,d in the text. For instance, square brackets (l "',,' I 1 ar uaed to indicate optionsl portion. of a comma.nd; cu e Iy brackets ( ( ""d 1 ) are used to indicate those por e.t ens that ow.y be repeated. So 11.1'1'1 C - J hun L<'~ th t the word LET is op t.f ona L and may be om.itted. And lIu.t H ~ Ion.. ", ~ar) 1 IlIdlt. I. '0 hn t the REJoIIIl:k command consists of the word REM optionslly 11111."",·d by on 01: wore characters.
IILII nl [01'1

M"'I.I\!:II'H'T· 0 llyn tax

ubbrev1ation. and definitions in a logical order for those m of symbols and definitions. dcflniti,ons until you encounter r to the alphabetized glossary

in the first part of Chapte.r 2 who Want to see how we've built You may prefer to ignore these one in the text. At that time, of syntactic term. given in

USING THIS MANUAL
This reference manual assumes you have a minimal working kno~ledge of progr.mming language BII.SIC. !f you·re. unfamiliar with BASIC., the ~ II ~ Programming Manual can provide an introduction: it covera a version of BASIC which 1s much 11ke APPI.ESOFt II, but simpler. the

h.lpi nr. ) through HI pte"ent detailed exp Lane t Lons of APl'LESOFT's commands, ~"lIr"d by subject matter. 1£ yo,,'ce interested in finding out about II "I"'" II I command, the alphabetized index On che inside of the back cover "III t"11 you whete to look. Additionsl reference material not covered in II... ''''I' c.rJl enn be found in the appendices. At ,u; " p laces you'll see th symbol

We r .. commend that you have APPLESOf'T II BASIC (usually referred to S9 APPL.ESOFT) up Bod running "'hen you consul t this manual, 90 t ha t ~ou can out on your computer anything the manusl describes or suggests. If APPI.ESOPT 1s running on your system, the APPLESOFT prompt character (J wiLl be displayed. gee Appendix II for an explanation of how to get APPLESOFT loaded into your computer.

try

)

ytUI

III ""Nllng 0 pn.t ag raph , IIhould be alert.

This

symbol

ind.1cates

811 unusual

f"ature

co ",hlc~

'III" N)'mbol
"

.

(Ir"o"d('H pnrIJllrapns describin,g sltuati.ons II, rue!) ... r , You vUl loae your program AI'I'i.I!SOJlT.

from which APPLESOt'T may be unable and "'ill probllbly nave to r,,-stult

XII

XUI

IMMEDIATE - EXECUTI.ON COMMANDS
Try typing the
PRINT 1\1-4 and then press Al'PL6S0fT 6 The PRHfT s t"temen t you typed key. APPLflSOFT ""81"a[ ..d tile v .. u .. in this case 6. 1, No.. try typing this: PRINT 1/2,3*111 (" means multiply, WIIe n YOu pr esa .. tbe was executed fOnDu.la after a" 800n as you the PRINT and preos"d the RETURN then typed out ita II fQii"wing the key .. : ",,,'d'ed RETURN.

I n I'he previous ex.ampl.e ,. we typed Lf.ne III first and li tie 2(1 aaccnd , U"wi'vC r , .it I1I!!k·e.9no d1 Herenc;' in vha t Older you type def ec.red-execu "UHI.,.ncnts. APPLESOIT al"'ays puu them into cor cecc numarfca], order "",·ord I Ill! to their line numbers. To""", .~ 116 tin!! of e e rungod
t

cion

will

1""""d.iately

pr

1n t

dlut

..,ml"nta

10

he complece program cu .... en tly their cor r ectvor d er , t:ype

in

memor)" w1 tit the

I,IST ;l:I'I'Lt:SQI'r 'w111 "epiy 1\1 1'lI.ltIT 2+3 211 VItlNT 2-3

or:t th

!lom ·t 1'''.<15 it is des! rab.Le to d·ele te II 1 ine of a program. al cage thee. Uo.'co.,p!l eh4!d. by typing the 110"- number of the li"e you wish to delete, I <llltIWed only by a press of the RETlIRII key. dIvide). APPLESOFT wi 11 priM:

Th is

18

I

mean"

RETURN key.

Iyp, tno Ill'

following:

.5
As you can subtraction.. twovaluea dlvldes en d1.6cusaion

311
aee , APPLESOFT does di v i,I1,,,, and muLtLplica tion, as <Ie11 a. Not·" ho'" a com.... ( , 1 "ae used in. tile PRlN'l: 'commandto print instead of JUSt ooe, 'the use of thl! comma ",1 th the PR!NT c<,I1!1mand e 4~·-char.a.ccer lin" into J colu.w.9 or "tab fields." SeE! the of tab Lields in Chapter 6, under the PRINT command.

I.IST AI'I'I,miUI'T will 111 I'R1NT 2-3 y"tI
),,1-111

reply

with,

t".~".
I YI"

hnve now dele."d line Iii! from the progra... To Ln"ert a new line III, JUSt type III "j,oI'{].n.l APPLSSOF'l to ,exec:u teo

There:ls no wily to &e t it followed by the new "to rem"n'

Llle· following' III l'IIIHT 2'~3 with

DEFERRED-EXECUTION
Commands 9\JchliS the

COMMANDS

t.I H']'
1I1'1'1,f{SUI'T .. 111 reply I\! I'~ lilT 2*3 II! l'k HIT 2-3

"immediate-execution"
"de[err.ed-executLon" a "line number". Trytyp:l.n.8 the

PRI.NT 8 t8 eemen ta you. have just typed 8fecalled commands, There is ano rner type ·of command called a cOllmland. Every d·eIe rred-e.xecu. Cion comOlllnd begine with A line mHllber is an integer from Il Co 63999. lines: os. ted

'rlo r" 10 on casLer way to replace line HI than deleting it and then I ",,,"rll uS II nc." line. :tou can do thie by JUSt typinll the new l i.ne Ii! (and I" ["K :the RlITURN key, of Course). APPLESOFT auuoma t.Lca 11y th r·0"9 aWBY !II,' rlld Ito" III and rup l.aces i e with the new one ,

,'"II

fo nOwiD8

10rRllfl' 2+3 211 PUN1' 2-3
(Reme!llbet.

each

lin'"

..")8 t betccmi

by

pressing

the

RETI1RN. key,)

'1 Yl'e p,t 1.1 WI'

I\!

tho It£f

[0

J-J

l1ow1ng:

A ""'1uence of d",r"rred-e"ecution commands is "811eda. "program." .lnstelld of execu dog defer red-execu t:ion statements immedi,ately •. API'6ESOFT BASIC 9,to[<>8 deferred-.execution commands in the APPLE's 1116mO"y" \.'hen you type RUN., API'L.ESOl'T first """"utee [he arcxcd statemen·t having the lo .. est line number', then tl1O! st!l'tement 'with the nexe higher line number. etc •• until the compl."te program has been execu ted. Suppose eacn line RUN AI'I'I.BSOFT

AI'I'I.~c!iOf'T "Ul reply "II I'IUH,T 3~3 ~~ I'K,rW1"2-3 I, In 10 not
mHH!lllIJo

with:

.... . Y

rcco"nMnded loter

In rl!mcnt of

that program 11ne9 be numbered cons"""tlvely' to 1!1g~r't a new lin,e be:tuee:n t .... existing 0 HI betw"e" Une numbers is generally sufficient.
ODt

lines.

it '''''Y An

you

type

R.UN new

Cfcmember

to

press

the RETURN key at

the

end

of

you .. ill

type): DOW display on your lV:

5
-I

II yo" 1I0n[ to erase the complete program cur rerrt Ly stored in m,,",or)'. type tlHW II yu,~ nr{l fin1shod runn tng one program, and ar e about to begin a nev one, I'll< tluTe to t:yp" NEW first. ThLs shOuld be don .. to prevent" mLxture of the ... Id and lie'" programs.

2

3

Type the f0110 ...1ng: NEil I\PPU',SOPr .,Ulreply

vi th

the

pro"'1't

cne raccer

t

I
No.. type LIST l\prLESOFr showt'''11

d1git to print after all trailing ze roes are point ia pIin t.ed. The· exponent s Lgn ",11.1 be pI uS ( + ) fot p08:1,tlve' and 181"111"( - ) for neg,ative. Two digits of the exponent sre n 1"'(1)111 prin ted; that 1s, zeroes are no tsu.ppresaed in the exponen t field.

If

there

is

only

one

""'pprc8se<l. no ""ci"",;1

"'i1l~ .. ply vith
that YOUI: previou's program is no' Long..,r s t Dred 1om ..mory.

TllIl v.alue of any llllm.ber e"pressed di'<lcribcd above is the number to l'oW r oi the Dumber to the right

in the torm of the left of the of the E.

.5ci.enUf1c notatlon E times III raised

to

as the

J

NUMBER FORMAT
We will dtg.ress fOl:" moment to explain the forma t of "u",bers printed by APPL.ESOPT BASIC. Uumbers ale stored in ternally to over nine dig.it s of accuracy. Yhen II !lumber is pIinted, only nine digits are shown. EVII'Y number may also have an exponent (a power-of-ten scaling f ac tor) • In. APE'l..ESOrr 'SASIC,. "real pr'l!ci,>10n" (a Iao called "floating pol"t") ,,,,mt be in the range from -I *1~-38 to' 1*111-38, OT yOl.J risk getting message. Us1ng addition or subtraction, y<)u may sometimes be able generate numbers sa large as 1.• 7*111-38 without the error me99age. whose ab."lute v.81ue is les .s than about 3*.Ur-39 ",111 be eonvar ced by AE'E'LESOI'T. In ,.. :lditio n to these limit.ation., true integer vaIues 1" the r ..nge hom -32'767 to 32767. When a number is p r Lnt ed, the fol10 ..1ng rules ate used tD determine exacc [or..,.t: 11 If the Qllmbel: is negstive, " !!linuS si~n (-) is printed. 2) If the absolute value of the nu .. her is an integer in tha range 0 to 999999999, it Is printed as an integer. 3) 1£ the absolute va.lu" of the number is geea rer than or equal co .111 snd lesa than 999999999.2, the number is prillced in fi·M.ell point lIoCat1oll, wi th nc exponent. 4) If tne number does not fsll undec categ.ori""s 2 or 3, scientific oo·["t1on i." used. Scientific not a Cion is used formatted as fello"',,: SX. XXXXXXXXE,sT! "her .. ","ch X is an integer ·co pr in.' r "01 p rec Ls ton numbers, and 1.6 numb"'rs an error to . A (lul!lbet ro ze.ro m.\lst be

'[h,· fol'lo .. lllg. ere cl<';""ples of ""tiou" AI'PtHSOf"r "ill use to print tbe",.:

nu",bers

and

..he euepue, fot'!!1EIt

OUTPUT FORMAT

n 6~lJ
-t

I -I

-2 J.t,!;!! /,S. 72f~S l"lIr211 -12.34S~7896*11l-1~

6523
-23.46

4.5J21il1l1il
IE+20 -1. 234S679E+1I IE~9

11I1I1I1I~1Ii!1I11 '1~Y999999

999999999
eene ean tUBed
"I> tQ

the

/I "",",b('o;" typed on the keybo a cd ,. Dr "numerio """liT""" """Y' hav .. as rna."), <l18.i[8 as deaired, <l1.ldcs. 1I0w,,-v , oDly the first ...r III digit9 I'''nth dlSlL is rounded off. ".. r Q'K!!IOple, if YOII type I'IUNT I. 234561816!i4321 III'PLF.SO~" ruspond S wi th

aee usually

ehe ma,d"",m

an APPLESO.I'L length of 38 s1golE1cant, and the

in

I. 2J4~6188

COLOR GRAPHICS 'EXAMPLE
lYjl"
l.~

Il

·.rh h
to 9. a

The leading S is the sign of the numbet, noching fot II positive number and minus .81gn ( - ) for a negat1v e number. One ncn-aeee dig,it is ptl.nted before the decimal point. Thls is .fol10"ed by the dec1rn,al point and then d,(!other eigh t d isi t·s of the man ti8sll. An E 1s the,n printed CEot Exponent), follo"ed by the sig;n (5) of the exponent; then the two digas (TTl ofth .. exponent itself. Lcad1ng ~eroe!l are neve r printed; 1.e. cne d igt t before the decimal is never ze Io. AIBo, t fell 1o.g se roes are never printed.

'" HI blackout the top e",en ty lines ..<II ~ ronr U.n." ,of te"c at the botto·m. l"lo'-rcsoluc-lon "color CRaphics" "",de.

of

text

y,,,,, .APfLE is

on Yol.Jr TV So recu no", I.n its

and

leav,,-

IInw ~JIl>n
tULOII .. I J "I'I'LIISOFT' will only respond "ith the promp'c it character, renembecs [.hat
)'OU

"nil the El.oshln,g
" yO'lIo\l <:(llor.

I

cuesoe , but

internslly

have

selected

tlnwtype I'I.OT 2'~, 21J
"PI'LESOFT .. Ill respond by plott Lng a !Omall yello .. squate in th" cen tet ot Lt,.. u<:reen. IE the square is no·t yellow, YQu'r TV set is not tuned properly; ~tJ !uu.t th .. tint and color controls to achieve a "lear lemon yellQ"'.' 4,

5

Ne", type ]fLU! iI,3G AT 20 IIPPL.ESOFI "111 draw the scre"",

a horlMntal
d01>l11

Un"

across to,,,.,

the

leftmost

three-quart.ers

of

one-q ua r tar

fr," .. tbe

No,", type COLOR 6 to change to a n.e" color, VLIN ill,39 A'I 311
B

and

then

cy'pe

II.. ~,,· OJ "hn e hnppe na When APPLESOFT "ncoun [era the INPUT st a te",en t, it dllll'l"1" II questio[lrnark (1) em the ac r een , and I:hen wa11:S for you to type a ""Hl1h"r.. When you. do Un the above example, 10 Wall typed),the vatl"ble I tlll,"",ing INl'trr 1s ass1g"ed the typed value (in this caae , the UIPUT worillbl" R "'as Set to L0). Then execution contnnues with th" next statement 1 "~h" p,rogralll, ",hich 1s line 20 in the above e)tample. When the formula "hili,. the PRINt IItatemellt is "val uat ed , the value HI ill substituted for the vnr1l.lbl" 1\ each tl .. e R appear s in the f.ormula. Therefor!!, the formula

buc~m~9 J.14159*1~*10. or 316.159. rr )Iou haven" t already dn:.lc "tth the 'radius guessed,
R.

You will

learn

,w,ore about
display

coler

GRaphics

la e.er.

to go. t back
showing

to all

text

the

progr'"m

above

e a leu 1a t as

the

a r ea of

a

mode, typ" tEla The character infonnatio"

on the

screen

Ls APPLE' s way of

color

J!!s text.

When PRlN'r1ngrhe a"""ers to problems, it 1s often des,lrabl". to 1nclude along wi th the answers, t.n order to "XI' Is in the. meanin8 of the numbers.,

t"XC

H "'..., ,",on ted to calculate the ar eu of vaI'iou" circles,."" could keep rCl-t'unnin,g the pl"ogl"am £01" each S'-UC'l; cas 1....-e cil"cle,. But there ~ s an easier "'{'Y to <10 1.t, simply by add1nganother line to the program, as follows:

Type Ch" follo,,1"8:
PRINT "ONE THIRD IS EQUAl. TO". l/3

II GOTO HI
RU~

APPLESOTI will reply Idth: ONE THIRD IS EQllAl.. TO

.333333333

11 II )U.159 28..27431 14.1 MI. 3':11123] flRI>I\K Hi l'
t

73

PRINT FORMAT
As explaine.d e.a~11er, including II co","'" (, ) in. a PRtNT S [0 t .... n ~ olluses it e to space over to tile nE'.l<t tab field before ehe va Lue following the comma 1s pr1n'l:ed. UOle usn a semicolon ( ; ) 1nstead of aCOmDlll, the II"XI: value will be printed immediately fol10,,1ng the previous val"e. Try it.

I

PllINT

1,.2,3

I
PR[NT 123 1;2;3

3

By r"'~t1'n8. Q COTO sta~.m"nt on the end of your program, you have caused it to 110 bock to line ill af t.", it prin.~seat:h answe.r. Tllta ,,,,auld 8,0 on I nd" [i" ite1y. but "''' decided to stopa£ tee ca.l.cu.Lat Lng tbe a.ee Eorthr",e Ire 1"9. Scopp1ng was accomp11shed by typing" control C ([ype C .. hUe l,01ting down the CIRL key) and (>roa91"8 the RETURN key. This caused s "brenk" in 'the program' G execur.Lon , allowing us to stop. USing ccnrro l C, ,my program can 'be s.topped after "x"euting the current 1nstructhm, Tt)' it I or yours"l E,

VARIABLE NAMES
j

PRUU -I

2;-3

-12-3
'the folloldog is an ,,-xamp1e of a prog.ram tha t reads keyboar'd nd uses that value to calc ulace and p1:int a va Iue f rOm the resul t:

rn« lener
ulmply "nrlnble by .mny
0

Ii

20 PRINT
RUN

HI

INPll'I

Thts 19 R inch. progrs." we just ran "as 'termed II ""ariable." A 'memory Loca cion 1n the co"'pucer, iden t if ied by the name R, "".m." mUB,[ begin .. 1 than alphab"t1c character ...nd may be fallow .. d aLphenumer tc char ac ee.r , ,A.n alphanumer-ic cha rec car is any Les ce r from " through Z. or any digH from 0 through 9.
11.( iable name may be up to 238 en" (a.cters e he fl~st t"'O characters to distinguish Ihe namas Go6D~NO(jGlIT .";d COLDRUSII reEe. to

.16159~·R

"

?lP

0""

long, but AI'P'L£SOFT u sos onl~ na"e from another. Thus, thBsame variable. after the firat
tWO

3U.159
In D vllriable 19uorc!l unless

nllme, any alphanumeric:
they con til t n a "reserved

char ac t.eea word,"

eel' to in words

used

are in

6

7

APPLB$Of'T BAste command. .. aX"e ii~eserved" for their spec'Hie purpose. You cannot use. 'these. words as va-riable naml2!S or as part. of any v,~r1able rtaUleii For install"e. I'&ND would be illegal because END is a reserved "o~d •.. The' rese'~ed ",,~ds in APPLESOFT BASIC are listed and discussed in Appendi" F. Variable in this "ameS ending chap tez under in $ Or % have lI,EAL, INTEGER, of legal and a speci".l meaning, as AND STRING VARIABLES. 111e,gal variable discussed later

IF ••• 1HBI
L. t'" "'fiu, a program to check ...mether a typed number is zero 'or not" With lh 8to~QmentB we"ve discussed so far. tMllcSn net be done. I1l1at we need 1"" .• 'tllte,ment that provides a conditional branch to anotb."IatateO\ent. The U""" '. THEN' stocemll.nt does just that. TYI'" NF.W., then type tide progra.,:' I~ INVUT Il 2' IF B .. II TIlBN OOT'O 5' JII PI! INT "NON-ZERO"

6elo,", a.e some e"smples
LEGAl. 1:P PSTC$

names ;

coum
111%

ILLEGAL TO (variable names cannot be, "eserved words) RGOTO (variable names canna t contain reserved words)

Beaide. ",seignin,g values to a ",,['iable "itll an INPUT 8 tate.mont, set the "slue of a varab1-e ",ith a LET or assignment at at emene-

you Call also

.4. CO'I'O III ~IIII11IN"I: "ZERO" lr~ OO'rll III
WI'''fithl~ pr.ogram RUN. it .. ill PdOlt a quas tion mark and ""it fQ~ you to l'P<:>~ vAl'"e fo r B. Type an)' value yo" wish. Tne compute r ',",i II then co"," t" I h .. IF stQCemeDt. Betveen the I. and tha THEN portion of the statement, r hor 1.:9 on ·',(Ulse'rtio'n. 'I' Art assert.ion eons Ls ra of two' expresoions aapa r a t ed by on 0,[ the folIo",ing Bynibols: MEANING SQUAL TO

Try the
A

5 PRINT A~ A·2

-

followtng

"x.a"",!"'"

5

[\1

L.ET Z 7 As can

~7
2
f['om tlr

GlU1A'rEl!. THAN

eRlNt Z, Z-A
be seen

><

NOT EQUAL 1'0

LESS TIIAN

the examp Les , the

LET 1s op't10081

in

an as " 19n", 1''' t

LoESS TI!A.N OTt EQUAL 10 GREATER TIliU'I OR EQUAl. TO III., II' ~tatc .. ent is either t rue -or f"lee, depending upon "hether the n IIU'''', rr tun ia. 'I:; rue ,oJ;" no:t ~ In OU~ p r'es en t I? r'ogra.mill for exa.mple oJ if 0 15 I rl, ..d for II the assertion II-II is true. Therefore. :the U' statement i,s t1:""e, ,,1101 ""'Hrm. e~ecutioll 1 CODtioues "'i til the 'tHEN por tion of the sti!i.Ccmen t, COTO ~~. HoUowing this command, the computer .. lll sktp to line 511. ~EIWwill h" I' r [,,:ted ,. MId then the GOTO s ta temen t 1" line &II .. i U send the compo tel'

s tatement,~ BASIC "r"lIIember~" type of 8[,{I<''''''''<lt.
lI!;'emory to, s'to:.:e

the va Lues that have Tl1is "~efi",'",b"ting"
the data.

been pro""

ossigned as use"

to variables USing apaee in the APPLE'

this
B

The ""l",,:s of va r Lsb Laa aze thrown away and the space 1n :memory used score them. 1,. .el.. ased when one of fOIl,r thin!!s eecur s s 1) A ne'" line 1& typed into the pro!!tam or sn old line 21
'ie de~eted. A CL.BAllcommand is issued. 3) A RUNcO",!Mnd ia issued. 4) NEW 1& typed. Here is another important fact' until all numeric vati,abl-es nre autolM~ly

to

bOt) to line
'IUI,IIHI<"
IIln""'Ullt

l~.

.

0 I is typed

for

II.

Since

tile

Ilssertion

.B ,- 0 is

yo.:! 119sign Bsslgn.ed

them SOme other the value zero.

value, try thie

:19 flll.se 8.lIdp,rogram "".cution conr i nues nm.11 "r" Ignoring tile THEN portion of the Btatement II, .10 1 line. Ttune.fote, NON-Z!;RO "i.11 be prin-ted w j I I unlit! 'the computer back e e Hne Ul"
N(I'" I ry ttl fo1.l.ow1ng prog tam kL~ IJr. , to delete your last 1101 IN:I'UT 11,8 I~ III It <~ B Til EN 50 for ecepar program): tng

no'" ralse, the l'F ...ieh the next lin" and aoy other sca cements and theCOTO in line ,49

e"ample:
PRINT Q. Q+2,

tWO nll.mbers

(remember

to

type

~

Q~2

Z

,
th e REM statement. REI'I is short fOT '''''''lrk. Th Ls insert c.ommeots, Dr notes in'te II I'regnll!l. Wh"" BASIC tem.n t the rest of the I1ne is ignored. Th1'S se rvea the 'prQgrammer'~ a,'nd serves ne 1J:9~ftll func.ti,on ul9 f'a r as program io sol v Lng a p"rdc.ula" problem.

CQ,a

15 ,statement ts used to encoun terS II REH s ta lDJ..!'I;i.nly as, an aid eo the oper,lItion of the

Another

S'tste,lnl!nt

tP'I'IIIN'T

"A IS LARGER"

" tOtO III ~II III /I <. II THEN GOTO 8~ 10\1 I'll urI' "'rilEY AII.E TILE SAME" I'll (;(l'tO HI H~ l'M'lN1' "II IS LARGER" "l~ crrro I~

B

9

When ~hi8 program is RUN, line L~ will print a question mark and wait for you ~o type two numbers, separated by a comma. At lioe 2~. if A is greater than B. A<sB is false and THEN GOTO 50 is ignored. Program execution then skips to the statement following the next line number, printing A IS LARGER. and finally Une 4(1 sends the computer back to line 1 ~ to begin agadn . At line 211. U A has, t.he same value 89 B, A<-B is true so tHEN 00T0511 is axecured , sending the computer to line 5(1. At; line 511., since A has the Same value as B, A<B 1s false. Tne r ef'o re , THEN GOTO 811 is ignored and the computer goes on to the following line number, where it is told to print TH.EY lIRE THE SAME. Fioal.ly, line 70 send the computer back to the be&innill& agaio.

til e:ommand OR tells the APPLE to switch to its color nlqo "lea.s the 40 by 4iJ plotting area to black, SetS wlndoll of 4 lines of 411 char ac rez s each at the botcom 1l~9 he n xt color to be plotted to black.

GRaphics mode. che text output of the screen,

It to and

a

(

to clear the text area and set the cur sc r to the top left currently defined text window. In color GRaphics mode, this wouLd be the be8inning of text line 2l1, since text H11e8 0 through 19 are bl'inR ueud fo~ tile color graphics plotting area.

norm Is used '''''''''1:" (If tile ,,,.w
'h"

Th.

OLO!!- commands 1n 11nes 23~ and vol II of the expression following

25iJ set
COLORa

the

next

coloI;'

to be plocted

to

At line 2i, if A is smaller than 8, A<-8 is true 80 program ~xecution cone.tnues wi tJl THEN GOIO 50. At line 50, A<B is true 90 THEN COTO 811 :is e~eeuted. Finally, B IS LARGER is printed and again the computer is sent
back to the beginning. Try running the last two programs several times. Then try writing your OWn progra .. using the 1F ••. TIlEIi statement. ActuallY trying programB of your own 1s the quickest andeaaiest way to understand how APPLESOFT BASIC work.s. Rememb ar , to stop these programs just type control C and preas RETlIRN.

II", 1'1.0'1' H.I:,NY command in line ZJI! plots a omall sque re , in the ye.llow color tI,,1 In d by the moat recent COLOR- command, at the new position specified by , ICHT'''"~IPUB N~ and m~. Rell1ember,!'IX and NY must each be a number in chI!! .... ,I!.•• II hro"sh 39. or the square will be off the Screl!!n and an error f I~ fli1Jt.· will fcsult_

Itmllnrly, PLOT X,Y in line 2511 plou a small square at the posHioo IP ,II j d by expressions X and Y. But, X and Y ere simply the "old"
,,,-urdlnntlls HX and NY, saved after plotting the previous yellow square. II",,,,,' or • PLOT X, Y [e-plots the "old" y"1h,,,, aqus re with a square whose ",I", III dllUned by COWR- II. This color is black, the same color as the I"" kl!.rnund, 80 he "old" yellow square seems to be erased. 111,11 To Bel from color graph1.rs Ii Xl' .m" lh,·" I'rOB6 the RlITllRN key. ('1,1
")I.

ANOTHER COLOR EXAMPLE
try a graphics program. Not.e the use of REM statements The colon ( , ) is used to sepa ta til' mul c lple 111.8 true tions On program l1ne. Af tet you type the prograOl below, l.IST it and you have typed it correct y. Then RUN it. Let's for cla.<ity. one numbe:o:ed make sure t.hat

back

to

all

text

mode,

r ype.

n:XT,

06

iOGtructed,

I ,,,,,~ •.

J 211 X 13G L~II 'tV

l~g GR ; REM SET COLOR GRAPHICS Ill! HOKE : REM CLEAR TEXl' AREA

MODE

.11 'I""Y It ~I II

"ymbuls on the screen in a text characters.
b 'xplaln2d in

your escape fro'" CRaphi"G ,""de. Ignore the they re.sult from converting your graphics If you don't understand line 29~. be patient. subsequent pagea. -

is

II ,
2 1:

y - S : RI!H
: REM REM SET SET X Y

SET STARTING ros ITlON II'Y

XV -

VELOCITY
VELOC

A. you hove 8 n. the APPLE 11 can do mor than JUSt use numbers. t'LUI" Ltl COlor graphics again, after you have lClirnecl more about
I\/IHII.

We'll
API'LESOFT

151.1 REM CALCULATE NEW POSITION 161.1 NX - X + XV : NY • Y + YV 1711 REM IF BALL EXCEEDS SCREEN EDOE, THEN L8~ IF NX > 39 THEN NX • 39 , XV • -xv 190 IF NX < II TaEN NX - II : XV - -XV 211~ IF NY > 39 THEN NY - 39 , YV • -~V 21 II If NY 0( II tlfEI! NY - II ; YV - -'IV 2211 REM PLOT In.:w POSITION IN YELLOW 2311 COLOR - 13 : PLOT !IX, NY 2411 REM ERASE OLD POSITION
251i COWR .. II , PLOT X, Y 2611 RI21 SAVE CIlRRENT roSITlON

BOUNCE

FOR ...

NEXT
Tile

lin, "tll/nM ge of computers 1s their abilit;y to pe.tEorm repetitive tasks. '1,,1'1''''''' \I ... n~ D tabl .. of o squa re roots .• Eo, the integers from I to Ill. AI·I·I.I~SOf'1' IlllS1C function for square root ia SQR; the form being : '1l<.(Xl wli'~ t. X i6 he number whose sque re root. you wish to calculate. We could w~ II" Ilw pros~nm as follows:

27\1 X - NX :Y - NY 28~ REM STOP AfTER 25(1 MOVES 2911' I - I + 1 : IP r < 25~ TI!.EN GOTO 16~
31l1! PUN'! "TO RETIlRN TO YOUR PROGRAM, TYPE 'TEXT ".

10

11

LII PRUIT 211 PRINT 30 E'RlN! 411 PRINT

50 PRINT
611 PRINT

I, SQR (I) 2, SQR(2) 3, SQR(3) 4, SQR(4)
j,

SQR(5)
SQR(6)

6,

7" PRIN! 7, SQR (7) PRINT S, SQR(8} 9\i1 PRINT 9, SQR(9)

8"

1011 PRINT This

IP.

AI I I II L II. N is se t to equa 1 1. Line 2!Ol cauaea the value 0 f N and the "rnl r., r nt, of N to be printed. At line J\l we see a new type of statement. II.. I~KT N 8 ment Causes one to be added to N, and then if N <a III I" "lIJ1". II cution goes back to the statement following the FOR. Ther" is ,,,.,1111111 IIl"ei 1 about the N in this case. Any variable could be used, as 111111\ "N i L III the Sa Ole variable name In both the FOR and the NEXT .'1111 "m"H'.N. .'0 ~ Lnat anee, Z I could be "ubsti tuted everywhere there is an N III II", IIh<lVCprogram and it would function exacrly the same.

SQR(lll) is terribly inefficient. the IF statem"nt just lie ean int.roduced,

program w111 do the job; however, it improve the program tye",eodously by using

""I" .... w.' ",anted to print
1111"11 lrClm [II to 211.

a table of square roots for only the even The f0110",111& program would perform this task:

as follo·ws: 111 N - L 211 PR[NT N, SQR (N) 3I1N-N+l 411 IF N <~ 10 THEN GOTO 20

III II III N l'ItIN'f Il, SQR(N)

til

N • IH'2 211 TlU:.N COTO 2(11 this program and l\l. This program th" can one for printing also be written

\I IN·

""'en this
lll-state.ment

program is prog~am

RUN. 1ts output above it. Let's

will look. exact Ly like loole. at how it works.

that

of

the

II,,, 'mllor at rue cure bet"ee" 'I" ,. nUl II for he numbers I to ".11111 I)", J'CIR loop just introduced: (II ~1\11 N - 1(11 TO 21J STEP I~ 1'lIllff N, SQB (N) '" N .Xl·
N

Hili.

In line 111, there is a LET statemellt whid sets the I. At line 211. the computer is told to print N and using II's current value. Line 2\1 thus becomes 211 PRINT 1. SQR( L) and the reSUlt of th1s calculation is printed out.

variable N to the val'Je the square root of N,

2

At l1ne JIJ. there is wh.at appea~8 at Hrst to be " rather unusual LET sta.t.emeot. Hathe_tical ly, the state.ment N - N + I is nonsense. HOW"VBl", the iJo.ponant thing to remember is tha t in .. LET • ta temen t, the symbol " - " does not signify equalit),. In this case" .. " meanS "to be replaced with". Th.e statement Simply takes the current value of N and adds 1 to it. ThuS. after the first tim through line 311. N becomes 2. At line 4G, since portion sends the N now equals 2, the assertion N <- III is true so the THEN computer back to 11ne 20, with N now at a value of 2.

flu' It. I II II major difference between this program and the previous one II 111 fOil. IIpa is the addi tion of the STEP 2. Ihis tells APPLESOFT to add I,. H .'n,·I. tiro-', iost-ead of I as in che previous program. If no StEP 1a ..... ." III n POR 9tn~emenc. APPLESOFT ass","es thac one is to be added each • I.., '. 110 STIW ean be followe,d by any axp re.ssion. 1f1'1'''.'
W.I

.",(t1 01 liu a III I • III

"""'ted to follows:

count;

backwards

ECOIDH! to

I.

A program

for

doing

this

The ov",(a11 r<>sult 16 that lines 211 through 4i1 are repeated, each time adding 1 to the value N. When N finally equals I~ at line 20, the next l1ne will increment it to II. This results in a fllise asae r t Lon at line 41l, t.he THEN portion ia therefore ignored, and since there are no further statements the program stops. This USing technique it. is referred to as "looping" or "iteration". In progrsmming, there are special BASIC sl10w these with the followIng progum: Since it La used s tatelJlents for

III I'IIINT I, III I 1-1 ~Ii 11.1 I • I THEN

com

2"

11111 .. are nOW checki<lg to see thac I 1s greater thsn or equal to II" II "" I v",1u The reason 1& that We are now counting by a negative '"1111" r , In he previous examples it "as the cppcat te , so we were che le.i_og I nr- n v.r,1 ht less. than or equal to the final value. J1,,· 111 I' "tatem n t previousl)' sbolffl can also be used with negative I" "I" I1lltpJ,!"h thts same purpose. This can be done using the same II .,,1 I.. th ocher program. as follo"'s: Iii WI!. I • III TO 1 STEP -I II I'kllfr 1 I" Nf.XT I nu.",bera format

NOli I.

qui te extensively
We can

I~ FOR N - 1 TO III 2101 PRINT N. SQR eN) 311 NEXT N The output output. of of the the program listed above previous tWO programs. will be ex"ctly the Same as the

12

13

FOR 1001'8 can

a150

be "nested".

An ""ample

of

this

procedure

follows:

II. nn " I j At

~Ilmple of ho,", arrays ate used, of 8 numbers typed by you.

try

the

following

program,

which

sorts

FUR I - I TO 5 FOR J - I TO J 3~ PRiNT I, J 4\1 NEXT J 5il NEXT 1 Notice what that tbe NEXT J comeS before the l-loop. The following NEXT 1. This is because the J-loap

HI 211

t
prog~am is iocorrect; RUN i~ and s'e

is inside of tbe
happens ,

l~ FOR 1 - I 10 5 2~ FOR J - 1 TO 3 311 FRINT I, J 41J NEXI I 59 NExt J

It does not work
the J-loop is lost,

because

when tbe

N~XT I is

encountered,

all knowledge

of

ARRAYS
It 18 often coovenlentto numbers., APPl.ESOFt allows An array name, is be able to select this to be done any element in a table of tlHough the use c f a rraya.

'III InM II (8) : DUlfNSlOfl ARRAY WITH tlAX. 9 ELEMENts 1\111 REM ASK FOR 8 NUMBERS 111,1 Pill - 1 '1'0 8 1211 1'10 ~t "TYP.E A NUMBER: "; lJlI INPUT A(t) Lfoll I~B)ff 1 Ifill"" I'ASS THROUGH 8 NUMBERS. TESTING BY PAlRS I"" V • II : IIEM RESET THE ORDER iNDICATOR I.7!J, FOR 1 • I TO 7 11111 I" AO) <.. A (HI) THEIl GOI0 140 1~1l RQH INTERCHANGE All) AND A(I+1) l!~~ T .. A(U 211#1\(1) - A(l+1) U!I A(j+l) -T ?'HI II' .. I : kEM ORDER WAS tlOTPERPECT lMJ NEXT I 1511 KEM f· {I MEANS ORDER 15 PERFECT ~b'" I ~ ~.• I tHEN GOTO 16g : REM TRY AGAIN 11101 l'R TIlT : REM SKIP A I..rllE ilill K HH PRINT ORDERED NUMBERS 1'111 .·OR I J TO 8 1\0111I'R lIlT A (ll 1111 IlKXT I
M

is a table of nu",bers. The name of thi" table, called the array any legal variabl~ name, A fo~ example. The array name A is d.lsti.nctand separate [rom the simple variable A, and you could use both in the same program.

II/h,." II no 911 Ls execu ted, APPLESOFT "etS aside s.pa ce fo ~ 9 nume ric "II LUG , s A(II.) lhrOllsh A(8). Lf.nas ll!,! through Ull get the unsorted Hat ttom rhe " er , 'fit" Borting itself is done in lines L7iJ through 24iJ, by going through III. 11 t of numbers aDd interchanging any two that are not in order. F is II." "p.'rrect ord"r indicator": F - 1 indicates that a SWitch '"'''s done. If ~IIY ...r'f(t done , line 2611 tella the computer to go back and check some more. II
llloY

To select an ~l~ment of the cable. we give A a subscript: that is .• to s eLee t the l'th element, we enclose I io parenthesis (1) nod then follOW A by this subscript. Therefore, A(I) is the I'th element 1n the array A.
NOTE: In this senion of the manual we wi11 be concerned with one-dimensional arrays only; for additional discussion of APPLESOFT relating to arrsys, see Chapter 5, "Arrays and Strings." commands

• e mpl,

"pass

is
were Not"

(Pl'tlnlngthey
nr t d list.

11"

made thtough the eight numbers without interchanging all in order), lines 2911 through JIll will print out rha t ,. subscript. can be any expression.

GOSUB ...

RETURN

ACI) 1s only Doe element of array A. API'LESOFT must be told how lIluch epace to allocate for the !Intire array; that Ls , wha.t the mIlximum dimensions of the ar ray will be. Thi9 is done wi.th a DIM s t a remenc , using the format DIM A(15) In this case, we have reserved space for the lIrray index I to go from 0 to L5. Array subscripts 111"ays start at I!; therefore, in the above example 101", hav" .. 11o""d for 16 numbers in array A. If A(l) reserves is used in space far a program before it has II e.lements (subscripts be n DIMensioned, through L(6). APPLESOPT

A""lll·r u.eful pair of statements are GOSllB and RETURN. If your program I' I J 0 ..... th" 88me action in several differen t places, you can use the GOSUS "ltd lU'.'tUllll StDtem nes t.o avoid duplicating til the sarae statements for the Ii< I lUll n L each place within the program. Will'" n aUSUB statement ta encountered, APPLESOFT branches to the line ,.hose .",mll". oHows GOSUB. However, APPLES OFT remembers whe~e it waS in [he I'"'' rllIl> b forC! it branched. When the RETURN statement is encountered, ""I' I!II PT goes back to the first statement following the last COSUB that '"'as II." ilL d. Conaider the followi.ng p rcg ra .. :

il

14

15

2iJ PRINT "WHAT IS THE FIRST NUHBER"; 3~ GOSlIn HIli 4iJ 'f = N ; RE21 SAVE INPUT s~ PRINT "WHAT IS TItE SECOND t~UMBER"; 61J GOSlIB I~II 711 PRINT "TUE; SU~I OF TRE TWO NUMBERSIS ": T + II B~ STOP ; RD! I>ND 0 F MAIN PROGRAM 1~1iI WPlIT II ; liD! BECtN ItlPUT SUBROUTINE H!iI U' N INT (~!) TItEIi GOTO 1411 J2G PRINT "SORR'!, NUl1BERNIlST BE AN INTEGER. TRY AGAUl." 130;1 GOTO 11.'10:1 1411RETI1RN ; REM END OF SUBROUTINE
B

lEAD ...

DATA ...

IESTOIE

"UPPOP(' you v .. nt you.r program to use numbers that don" e chang" each time the ""'I!cnm ,18 run, bu t which a.re elLsy to change if necess. ~y. liASIe Con tains ~ P"Q fn L 8 rn em n tsfor this pu.rpose, called the II.E.AIland DATA 5 ta teme.n es ,

r~""'Rld

r the

follOWing

pz og .. a1l1;

This program asks f01: two nUlDbers which ",uat be integers, and then -prints "he sum of rh .. ~o. The subrout.in .. in this program is lines 1!il0 through 140. Tbe subroutine asks for a numbe.r, and if the number typed io resp.ons is DOt an integer, as Its for a numb .. " again. It will continue to aslt until an integer value is typed in. The maio program prints WHATIS THE FIRST NUl1BER. and then calls the sub rou tine to ge t the va lue of the IIu.mber N. When the sub rou c1 ne RETURNs (to line 4(1), the number tho: t "'liS typed (tl) is saved in toe va riabla T. This is done so tha~ when the subroutine 1s called a second time, ~ne ",alue of ~he fi~"t number will not be lost. WHATIS THE SECOND NUMBERis theD printed, and called, this ~~me to 8et the se~ond number. the 9ubroutine i8 again

L" I'III.NT "CUESS A NUMBER"; LNl'UT G ItF.AD D 1.11II' 0 .. -999999 THEN GOTO 911 'U 11' II <.> C THEN COTO 3~ 611 !'RINT "YOU ARE CORRECT"

211

JI'

'III I'ItINT "SAD GUESS, TRY AGAIN," '/~ KJI;S-rOIlE 11111(;OTO 10 1111 IlAU. 1,393,-39,.28,39I,-8,II,3.14,9G

711 Elm

1111 DATA
'I'hh

89,~,11l,15,-34,-999999
happens "hen th" program 1s RUN; when the READ statement effect is tbe same as an INPUT s tlltem.cnt, but 1nstead from the lte)'b08~d. a numbe .. is read from the DATA is of

18 "hDt

'~'I!,,,\,,,cQr.{Jd. tbe ".tUng n number
.11.11
t!mt!nLS.

When the subroucille RETURNs the second time (to line 70), THE SUM OF TRE TWO NUMBERSIS is printed, followed by the value of their 9um. T contaios the value of the first number that was typed, and N contains the value of the second number. The next statement 1n the program is a STOP statement. This causes the program to SlOP executioo at line 8~. If the STOP statement were not included at this point, progralD execution would "fall 1nto" the subrout.ine at line 1~0. Ihis 1s undesirable because we would be asked to type still another (lumber. If we did, cne subroutine would try tQRElllRN; and since there "'as no GQSUB which called the sub rcur.foe , an ar rc r would occur. r.ach GOSUS ill a program should have a ",8 t ch ing RETIJRN execu ted 1a ter, and a RETURN shQuld be encountered only if it 1a part of a subroutine which has been called by a COSU~. Either SlOP or END can be used to separate a program from ito subroutines. STOP will print ~ message saying at what line the STOP was encountered; uill t"",,inat" the program wH:hout any message, 80th commands rut urn control to the user, printing the APPLESOFT prompt character J and a flashing cursor.

tim a number is needed for a READ, the irst number 1n the .first IIAIA .. U l m ne is returned. The second ti.me one is ne .. ded, the second "lIml",. in th first DA'tA statement. is returned. When the e ntire contents ,,' t he Jut DATA statement have been read in this manner, the s e cond DATA "' ""II~nt "'ill t hen be used. DATA is always read sequentially 1n thiB r , nd there may be any number of DATA statements in your program.

'Ihr t frAt

, "n,,,

11; 1''''P08C of th1.s pl'ogram is to playa ittle gaIDI! 1n whic.h you ny eo up_ n one gf the numbe."(s cenea rned "ill the DATA statements. Fo r esch guess , hll t I" typed in, the computer reads th rough 811 of the number's in the DA.TA ~,,, I ".,,'nLs until it finds one that .... tches th" guess, If READ r e cuz us ~'~9~99, all of the available DATA numbers have been used, and a new gue •• mmH be n.odc .. II Lo. !l01ng back to Ltn e III for another guess, we need to make the READ I"'lil" wl.th the first piece of data ag8111. Th1s 10 the function of the KgSTOR&. A[ r RESTORE is encountered, the IIext piece of data READ will In be he first item in the first DATA statement.

END

11""1\
I

lito tem nts may be placed anywhere within ttullenes make use of the DATA statements in It,,·y re ""couneered during program execution

the progulII. Only R£AIl 8 prog ram, and any ·other they will be ignored.

time

16

17

REAL, INTEGER AND STRING VARIABLES
There are three. different type.s of variables used in APPLe;SOFT BAS1C. Sq far we bave just used one type -- real precision. Numbers in this mode. are displayed with up to nine decimal digits of accuracy and ..ay ranSe up to approximately l' to rhe 38th I'ower. APPLESOFT ccnverea your numbersfrorn de"i .... l to binary fOT it.s internel use and then back to decimal when you !lsk it to 1'RlN'r the anSwer. Because of rounding ar ror s and other' unpn,dictablee., internal math routines such as square root, divide. and exponent do Dot always &iYe the "xact number that 1I0U eXl'ected. The number of places to the rounding off the value prior accomplishing this is: right of the dec Ima.l. point may be sa.t The general formula by for

II Y"u nlgn a real "umbe~ to an integer variable, and the" l'RtNT the value .. I th" tnt eger variable, it is as if the :un: function had been applied. No "u. ", .. ,_1,_ conversion is done between strings and numbers: assigning a nu .. h"r to n string var Lab Le , for instance, results .in en error neasaga111o... l·'''r. rh Ie n re special . functions for converting ene typ" to the other.

STRINGS
A ""IU!!I1 " of characters is r ef e r red to as a "11teral". A "at r mg" 1s a I It ..r .. 1 n 108 d in quotation marks. These are aU strings: "1111.1." "Altttl ..E" "TIIIl! lS A TEST" I,J~" n ..m~ri variables, string variables can be assigned specHic values. '111"11 vortnblca are distinguisbed from numeric Variables by II S after the Vnll I ih l .. nflt'l'l "~"ml'l , try the [011" .. ing: "tWill) HORNING" 1'~111 M 1.lllln fIURII!NG I... h!" 'M'",pl .... set ~h" string e IUIHII/I:". I ".

to PRINTing it.

In this case .• D is the number of decimal places. number of deCimal places is to let p~10-O and use where above digits

X - INT(X*la-O+.5)/INT(10!D+.5) X • INT(X*P+.5)/l'

A faster way to set, the formula:

the

p~HiI!! is 2 places, pa10!il0 f.s ::I places. etc. The works for X>-l and X<999999999. A routine [0 limit the number of a"ftcr the deci!lllli point 18 given in the next aee t Lcn in thi.. Ghapte,r. P~HI is One place,
uaedln APPL.&SOFT

'"

The table below summarit". the three I:.ypes of variableg BASIC programRdng: Description Symbol to Append to Variable Name

variable

A$ to the
we can find it contains).

sl:.rins value

"coon

""w
11.$ ALPHA $ 11%

St.rings (a to 255 characters) Integers (muSt be in raoge of -32767 to +32767) (Exponent -38 eo +38, with 9 decilDlll digitS) An intege.r Or string variable that variable. For example,

s

w hoy set AS to a string value. tlld v.oil> ts (the number of characters 'II ,III '1I11Il!W, • I",I,H' 1.I,N(f($l, I.EN("YES")
I'
I. I"~I I h"

out

what the length We do this as

3

ell
nOlle C

1111 1.11 rlln r Iun

Ileal Precision

ru

returns LENgth.

an

nreger

equal

to

the

number

of charactera

in

a

ao\'
O~

mus t be followed by a % X. XI and XS are different

$ at scb variables.

use

of

Integer variables are not allow d in FOR Or OEr Hta ementa. The greatest advanuge of integer variable8 is their use in array operation.s ... erever h

pOSSible, to save storage spaee.
All ariehmctlc operations are done 1n resl precision. Integers and integer variBble values are converted to ,eal precision before they are used in 8 calculation. The functions SIN. COS. ATN, TAN, SQR, LOC, EXP and liND also convert their arguments to real precision and gille theit results as such. When a number FOr exemple: is converted to an integer, :It, is truncated (rounded down).

ttl
.,

nllPIIIIr 0 f chllracte [8 1n a string exp r esarcn mal/range from rfJ to 255. A 1I1~ will 11 oon[1I1n8 II characters is celled a "nu I L" string. Defore II .1 I 1111\ • r tnb l.e is set to .. value in the program, it is io1ti(llL~ed to the .. "II ~, '"11' PRWTi1l8 a null string On ehe t"'minal will caue e no ,, to. I, .. ttl bO! printed, and the cursor ... ll i not be advanced co the next " u , ,. y h (ollowing: 1'111 HI 1 ,ItII (11$ J; Q$; 3
.1 I

~", ..I..,
.. lin

II

'f

[0

create

the

null

string

is

to

use

"

I It"

"'I"lv
- ""
t

1 ne s areeenc

III

U'

tl~'II"II" ." itlll

U-.999 PRINT IX, 11

A%-.lilI
PRINT AX -1

r Ing vlI'riable to the null string can be used to free up the by a oon-nu.lI string varisble. But you can get ill to ,'PIIII '*,I~J.II"Jnll the null string 1,· to a at r'lng .lIriable, as diseusaed in I 1 u ndu~ the IF statement.

'I,," ,. uned

,,,,pt ••,

18

19

Ofren it '18 desirable to retrieve part of a stJ:lng and manipulate that we have sec A$ to "GOOD MORNING", we might want topt:int out
fllur characters We "ould do So Uke E'RINTLEFTHM,
4)

ie. ollIy

Now
th ..

first

of this;

AS.

c:
fI fl

P,!lt example" I'OIIN-I 1'0 LBN(A$): I'RlNt IfIII${A$,N,

1),

HID$(A$,N,2):IIEXT

N

Q

GO 00 OD
II 1'1

GOOD
LEF1S(A$,N) 15 a string function "hi~h ""turns a substring 'composed of the' 1,Mt:moEilt 'N eha.r ae t.e r a ofit.s s:tring a t guman t , A$ in thi,g case. Here"",!) another example,; FtlR N .. [ C GO COO COOO

M n
II N N

itO
OR R~ Nt HC

to

LEN (.AS)

PRlNT LEFT$(A$,N)

NE;XT II

tN

G
S" C1HlP'tc'~ 5 for

G
more

deta lls

on

the workings

of LEFT$,
t,osether)

RIGHTS through

and 1'110$. the use 0)£

GOOD
COOD K

GOOD HO
GOOD GOOD GOOD GOOD GOOD UOR MORN MORN! MORWIN tlOR,NWG

ih dnfl~nmy aho be concatenated (put or joined t '[n- pl1.16 ( + ) operator. Try the. following: n$ • AS + Ii' uBILL.'" I'RIII1' ns (.Olll) MORtlING lULL
tl ...

Since AS has IZ<hara.ot .. r s , this loop will be executed with N"I. 2, 3, .... II, 12., Thl!. first time t,hrough, only the firs ,cha eac te r .. ill be pr illt,el:!: the' second tim" the first twO) ehaeae cura will be prLn ted, et c , there
is another string function called RIGHn. RIGIlTHM,N) returna the dghtmoe t II char<l,.,ten ,from the at riogex'p·(esaiooA $. Try substituUng, RIGln:s for L.EF'f$ in the previous ")rampl,, and see wha.t happena.

is especially usef"l if you w1'.h to take" str1"B apart {,- back [.og"ther with alight ""odifioation.,. For instance; U~ -, &)(II11'$(B$, 3,) ... "_,, + LE.FTS(8$,4) + "-" + KIDS (B~"Ii, 7) t'n"~"t ..n.. tlon

and

II",,, put

I'"INT C~ I! I !.1.-f:()O])-I!OIUnNG , I:n,,.,t h'l!~it is desi,rabl" to convert a numb". to its stri\"\,~r'eprese"ta ", ..I vto('-Vt8n. Tbe 'Eun·cti,on., VAL and STilS perfo·rmthese tsalts. Try 1 .. 1111,,10[;,; I, lit I NG$ .. "561.8" I'lt HIT VAI.(STR LNG ~) Uon the

1he~e is also a string
odddle FOR N of ""trins. 1 TO LEN(A$)

fun.,~ion ",hich a 110.,," us to take character.
Try the follo"'ing,; IIID$(A$, ; PRINT

£"om the

~','.II

III ,

NEXT

N

MID~(A$:.Nl re'turns a substring .tarting at the Nth position of A,e to the end (last eha rae t ae) of AS. Th" first pca Lt Lon of the string is position 1 and the Last poasdb Le position of II string 1's position 2!>S.

nTRINr.s .. Sl'M(3.14IS} "ItI'NT fiT1l1't;c,~,LEFrs I.UIS. J.14I

(STRINGS,

5)

Ven' often, it i~ d'eslrable to extract only the Hth character from ,8 stdos· Thi$ can be done by calling UlDS vHh three argumanrs : MIII$ (AS,N,l l. rhe third IHguonel'l't specif:ies th" number of characcer a to be returned, beginning with character N.

, h~ ll'l1\$ functilln can b" used. to change numbers to e. certain for!l!1lt for JnIH.L or output. You can convert 11 number' to a string and. tile" uae LE'I'T~, It IIoIIT$, ,~Il])$ and. ccuca cenac tcn to refOl"lllllt the nu,"ber a9 desired.

20

21

Tbe following sbort program format numeric output'

demonstrate.

how sr.r tng

functions

may be used

~o II yo" hov an application where a user is t·yping a question such as WHAT I STilE VOLUtI.E OF A Cn.UiDER OF RADIOS 5.]6 FEET liND II, reur s. 1 FEET? yULO n "110 the VI\L function to extract tbe nume<ic vslues 5.36 and 5.1 from Iii' ql_l Gtl.on. Addi~ional information on the .•" functions and CRRS and ASC 1s I" Chnptl'r 5.

111" INPUT "TYPE ANY NUMBER: ": X 11" PRINt : REM SKIP A LINB 1211 PRINT "APTER CONVERSION TO REAL PIlECISION," 13" INPUI "ROWMANYDleITS IO RIGHI OF DECIMAL? '': D 1411 eOSUB HIIlII 1511 PRINT "***" : REM SEPARAtOR 1611 GOTO LfllI 11l"!1 X$ - STR$(X) : REM CONVERT INPOT TO STRING llillil REM FIN·O POSITION OF E, IF IT EXISTS 1~21il FOR I - 1 to LEN(X$) lll311 IF ~IIO (X$ ,I, l) <> "E" IREN !lBXT 1 $ H14~ RElM 1 15 NOW AT EXPONENT PORTIOII (O}! E.ND) 111511 REM nNO POSITION OF DECIMAL, IF IT EXISTS l(,16(i FOR J - 1 TO 1-1 1"711 lP H.lDS(X$,J,I) <> "." THEN NEXT J 1"8!1 RElM J IS NOWAT DECIMAL (OR END OF NUMBERPORTION) 11l91il REM DO 0 DIGITS EXISI TO UGIII OF OECIMAL? ll"lil IF J+D <g 1-1 IHEN N - JtO ; eOIO 1131il : REM YES 1l1i! tf - 1-1 : R£M NO, SO PRINT ALl. DIC1TS L1211 REM PRINT .NUM6ER PORTlON a!lDE'.XPO~ENT WRTION 113G PRINT LE:FT$(X$, II) + MIDs (X$, I) 11411 R ETl1RN Ihe above pro,ra~ uses a subroutine starting at line 1000 to print predefined real variable X truncated, not rounded off, to D dlg~ts decimal point. The variablea )($, I and J are used in the subroutine local variables. out a after the as

, Iu- (tlllOWc!ng ptogtam

sor rs a list of string data and prints nlphnb tl7.ed Ust. This program is very similar to rbe one I.. Dortlng r 11 nuaer Lc list. 11,1(1 ))1101 A$(l5)

out the given earlier

I 1\1 II' )\$ (Ll <- A${l+L) THEil GOLD lSIt 11,11 )\$(1+1) 1',(1 1\$([+1) - Mel) 11,\1 AS(I) - T$ I/~ ~ I IH\I I - I I : IF I c_ 15 THEN COTO 130 1'111 If' F - I THEN COTO 1211 JII~ PI]" I - I TO IS ; PRINT A$(l) : NEDrT 1 nil DATA AI'IIl.E,DOG,CAT, RANDON ,COMPUTER ,llASIC ~JII I)ArA HONOAY,"U*ANSWER***","FOD: .. J iI "AfA OHPU'rER,EQO,ELP ,H1LWAUKEE,SEATILE,ALBUQUERQUE

IZ~ P - Q : 1 - 1

Ill'

1I0fl J • I 'to 15 : READ A $ (1) : NEXT t

r, •

MORE COLOR GRAPHICS
v lous ""amples, we· ve el<plained how the APPl.B II can do color runn S woJ. as text. In GRaphics mode, the APPLE displays up to [6"0 ,.rll 8Q" r 8, .In any of 16 possible colors, on a 4111 by 4<1 grid. It also JH "V ldl'll {, I Lncs of text at tbe bottom of the se eeen, The horizontal or ~ ,I"IN I~ dtondal:d, with II the leftmost p08i~ion and 39 the rightmost. The ~..rt II' "I 0 r y-axis 1s Don-s tandard in tbe t 1 t is inver ted: ~ is the 1.'1".... I 1)<>1j(tion and 39ta tbe ~mmo8t.

l.ine HI!!!! converts the real variable X to s[ring variable X$. Lines IP20 and Ig3~ scan tbe string to see 1f an E 1s present. I is set to the position oE the E, or to LEN(XS) + [ if no E is there. Lines llil60 and lIil711 search the string for a decimal point. J is set to the position of the decimal poinr, Dr to 1-1 if tbere i. no decimal. Line 111111test. whether there exist at le.oat [) digits to the right of the dec 1.... 1. If they do ex.!" u , the number pc reion of tbe s t ring mile t be trunca~"d to length J+D, which 1s D positions to the right of J, tbe decimal position. The variable ~ is set to this length. If the~e are fewer tban D digits to the right of tbe decimal, number pe e t Len ;my be used. 1.1ne 1110 sets the variable N to tbe entire tbis length

(t-ll.
Finally, line 1130 prints out variable X s.s de concatenation of two Bub-strings. LEFTS (X$,N) re turna the significant digits oE tbe number po r t ton , and HlD$(XS,I) returns cha exponent portion, if it was tbere. STR$ c!ln also be used to conveniently number ~ll take. For example: PRINT LEN(STRH33333.157) find out bow many print-pOSitions a

9

22

23

I(J

211

411 611

311
511

711 811 91i

11111

ua

12G 139 1411 1511 1611 17!1

18!! G01:0 1511 1(11111PRINT "~""HIT

COLOR GRAPHICS; SET 4IJX4!ol T'D BLACK. SET l'EXI WlNllOIiI TO 4 LINES AT BOTTOM HOME: REM CLEAR ALL TEXT AT BOTTOM COLOR" L : Pt.OT II.!! : REM MAGENTASQUARE AT (I,!! LIST:l!J: cosua Hllla COLOR - 2 : PLOT 39,0 : REM SLUE SQUARE AT x~39, Y=i1 HOME : LIST 511: OOSUB HI011 COLOR - 12 : PLOT 11,39 : REM GREE.N SQUARE AT X-II, Y.. 39 HONE : LIST 7(11 : casus 1\1011 COLOR .. 9 ; PLOT 39. 39: REM ORANGE SQUARE AT X=39, '{~,39 HOME : LIST 911 : COSUB 1111111 COLOR" 13: PLOT 19,19: REM YELLOW SQUARE CENTER OF SCREEN HOME ; LIST IlG : GOSUH lPgll HOME : PIUNT "PLOT YOUR OWN 1.'01N1'S" PRINT ''REMEMBER, X & Y MUST BE ~-!il .. <-39" lNPlIT "ENTER X, Y: "; X, y COLOR - 8 : P['Ol' X, Y : REM BROWNSQUARES PRINT "TYPE 'CIRL C' AND PRESS RETURN TO STOP"

GR : REM INITIALIZE

Type the following (rc'on;)mber to type Ii GR : nOME

HEW

program and first).

RUN it

to

d1.play

the

APPLE's

~ange

of

colors

2" FOR 1 • 0 'IO 31 JIJ COLOR ~ 1/2 4~ '1UN 11,39AT I 511 NaXT t 6~ FOR I - ~ TO 14 STEP 80 FOR I • 1 TO
It PRINT
7'J ?RIIIT

PRINT

TAB(I.Z

+ Ll; 1;
I;

NEXT I NEXT I

sa

15 STEP 2 PRINT TAB(I*2 + 1); PRINT "STANDARDA1'PLE COLOR BARS";

GQlo~ bars are displayed at double their normal "idth. The leftmost bar is bID k UB by COLOR-II; the rightmost, ...hite, is set by C;OLOIl-15. D"pending on the tint setting on your TV, the second bar as set by COLOR-L w1ll be mas"nt,a (reddbh-p"rple) and the third (COLOR-2) .. 111 be dark blue. AdJuSL your TV tint control for theae colors. In Europe, color tints may be diU r ot ,

""C;

ANY KEY TO CONT1I1U&***";:

GET A~: RETURII

After you have typed the program, LIST 1 t and check for typing errors. You may "'ant to SAVE it all caasette tape for future use. Then RUN the proStam. The command GR tells APPLE to s"'itch to its color GRaphics mode. The COLOR commalld SetS the next color to be plotted. That color remains 8t until changed by a ne'" COLOR command. For example. the color plotted in line 16Q r"mains the same no matter ho'" many points are plotted. The value of the expression fo110"'1ng COLOR must be n tlie range 0 to 255 or an error may occur. However, there are only 16 different colors, u8ually numbered from thtough 15.

1'" tho lost program" comma.nd of the form VLIII '1'1, Y2 AT X "'as used in line /011. ThIs command plots 8 vertical line from the y-coordilla te specified by ~xpr"88ion '1'1 to the y-coordinate speci led by expression f2, Bt the hnri",ont81 pOSition specified by Cll<pression X. '1'1, '1.2 and X must evaluate LO Yl'IlueB in he range Ii through 39. Y2 may be greater tlian, equal to, or HmlllJcr than '!t, The commalid HLIN XI, X2 AT Y is similar to VLIN except thlll j plots a horizontal line. No e! The APPLE draws an entire line just as Lt plots a single point! as easily

P

Change

the

program

by

re-typing

lines

15(1 and V,

L6(1as

follows:

HIGH-RESOLUTION COLOR GRAPHICS
NQw thnc you are familiar with the APPLE's low-resolution grapnics, you "'ill Ul'ldchllt undeutsnding high-resolution gra.phics is easy.. The commands have a sImilar ppearance: usually they are formed by just adding an H (for High r~DQlutton) to the oneS you already know. For illstance, the command

150 INPUT "ENTER X. Y, COL,QR: ";

1611COLOR No", IIUN the as points.

x,

z
select color your runge own colora aa in a moment. "'Bll

Z:

E'I.OT X, 't and you will demonstrate be able to the A.PPLE's

progrs~m We will

IIGR
The PLOT X, 'I' cOlDlIIlInd plots s small square of color defined command at the position specified by expressions X snd Y. must each be a number in the range 0 through 39. The GET instruction 111 line 1!!0(1 is simUar to waita for a sl081e character to be typed on the character to the variable follow1ng GET, It 1a RETlIRN key. In lille tlll(l~, GET A$ 1s ju.st used key is pressed. by the last COLOR Remember, X and Y high-resolution graphics mode, clears ehe high-resolution screen Q and leaves 4 lines for text a t the boecom of the screen. In [l'Ii8 ."".1", you are plotting points On a grid that rs 2811 x-positions .. ide by 16!il )1-1'0 1 10ns high. This lets you draw On the screen with Dlueh more detaU th " lh log by 41J grid of low-resolution graphics, Typing TEXT returns you 1<> the normal teKt mode,
" p

hi !lek,

an INPUT instruction. It keyboard, and assigns that M.£ necessary to preas th ... to 1,1&01' the program until allY

Remember: To gct from color greph1cs back to all teKt mode, type IT::XT and then 1''1'''99 the R.ETUR~ key. The APPl.ESOFT prompt character will reappes[ .

In dd1c'ion [0 [he IIOR screen. there 1s also ~crll II ~"u I:on use if your APPLE <:ontBins at Illllh-rcsQlucton gl:apllic.s mode for the "second Lh eOPllllllnd

a~ high-r,,-solution least 24K bytes of .. emory. page" of memory is invoked

by

lI(l1tl

.th,,"

Thl9 clctlt9 the I!lItl." ac r a .. n to b Laek , sivins you I. 2811 .-poBitiO~oSS by 192 y-p'os cions high, t"'Ltom. "gain, type TElI1' to aee your program.

a plotting surf".c,> and ne tel<t at the

chllt

24

25

Sound
:{9

ne'" ,,'bi1ay:

wonderful? there

It is; but are fewer

you do have to .. ake ~ colors. 'rhe color for

B""'<1£i,, e f,o( hillh-reaol"tion

eM,s graph!c

..

set by a command of the form HCOLOR - H "here N is " DUmb .. " f tom III (black 1 to 7 (wh1t.. ). See Chapt e r B f or a complete list of the colon "v..i,13ble. Because of tbe cons true tion of colo,t: televisions, these colors vary from TV to TV and fro .. one plotted line to the n a ,,'t.

'11,(1 1611 JH~ 1;1111

F.OR Y .. iii T-O FOR S - ~. TO I!COLC)R" 1 .. Rfll DRAW LIN

4Z11
I,II'J' 1,6iji
h8U'

158 STEP n; ; REM STEP THRII Y VALUES I : REN 2 UNI':5. FROM Y AND \,+1 S ; REM FIRST LINE BLACK, NEXT WHITE ETHIlDUCH "CSNTElt" TO OPPOSITE SIDE IIP1..0T 279. Y+S TO A,a TO lll,lS9-Y-S !liEX'I'S. Y. t'OR PAUS Eo<]
[:0"1'0 [2il : REM

TO

PinaU_y, there is oneeas,y instruction for gr"phics. To see thia in action. type HCOLORJ
IIGR lll'LOI

all

plotting

in high-resolutiDn

DRAW

15(ilG ; HSXT PAIJSE A NEW PATTER!l

REM

DEI..AY

IJ!ll, i'!llil The last command p,lo[s a higl1-resDlutloll dot 1n the color you set "'itb IlCOWR ( .. hite.} at the pOint X" 1311 ,y-lgill. As in low-re.o Lut10n graphics, x"g is at the left edge of eh .. screen, increasing to the tight; y-I! is Dt the .!El! of the sc reeo , increasing: downward., Had.mum value fD" X 1s 219; m8x1.mll.m y is L9, (but in FlGR's m:i.xed graphic5-plus-textm.ode, y values are"
ooly '"i..ibl" do"" to y"!.59). !low type HPLOT 211, 15 TO l4!>, B(I Like magic, a white 11"" is drawn from the 'f.oint 1<-2(il, :I-iS to the point ,,"145. ,,"8(1. HPLOT can d raw lines be tween any tWo poin ts on the sc r'een -horizontal, vertical. or aoy a ng l.e. Do you want to connec t ano the r line to the end of che pre" Ieus one? Type ILPLOT TO 12,. B~ This form of the commaod '[akes its starting point from the lastp_01.nt pr,eviDus1y plot ted. and dso takes itscDlor ft:om that point (e"en if ygU have issued a DeWHCOLOR command since that· point '\loS plOtted). You C8n even "ehaan" these cO!ll!ll8nds In one ins t rue Cion. Try .[hi.5: "-PLOT ".010 279,\1 TO 279.159 TO Ill. 159 TO. 0,iI You should now have a ..hi~e bocd.e-.- e round all fDur sid'es of the screen! ilere"'s a pr'ol,ram tha.t d't&Y9 pre'tty Umoir,e" pat.terns on yout' screen:

1"h I" h 0 ruche r Loug p:tDgtS...; type it in carefully and. LIST it in po r t Lens (,!.1ST11,3211 for instance) to "be"k your typing. We'''e added a apse .. between ""III" 11noe to IMkc' the program easi,er to read. Your LISTing will no t ehow rl"J~" "pa~"". lihen you lI:re sure it is correct, RlIN the program.
\IT/,ll und !lTAB ore ·cursot-mov1ngco"''''''nds, used to p'ril1t " charscter at " Ilfll-d "[ f""tned pOS1 tioo on the rexr sc reen. VTA.8 I places the cursor 1n th e I "II I tnn ;;vtA'B 24 places, it Ln the bo nOD! l1ne. !!TAB 1 pu tl.l the cur scr :tn [11" It, (~"1I!CI"t po!;Uion on 'the~ut"re!l t 1 inc; RtAB 411 pu t s it tn the righ tmos t I,nrlltlon.. In- II I'RINt instruction 11k ... ~he One at line 2i10, you may need a I I HU I 6(ml;i.eolon ee a'V'oid a, iSubsequen t "line feed II tha t diapl.ac.es yOllr
j'f~!~,;pu.nR~·

11.. 1uue t I.on RND (Il), where N is any posi tive number. r e turns n r cndon number !tt lho runge £,rom III to .99.9999999 (see Chilpte.: [0 forn com.plete df scuas Lcn ",,[ ~ND). Thus l111e HI!! assigos to tlle integer vll.rub1,e 1% 11 rsndo,", "u",-ber r • .,m 2 to 5 (0 !lUmber is IIlways rounded down whan it 1a ccnvertad to IIIl 1~,t.'III"r). The STEP s1~e in II rOll ••• NEX1loop docs not ha.ve to b. an !nH'II"r, but it may be easier to pred1ct the reauj cs for an integer STEP.

A. ~,,., " .. " In Hnes
.. """ t

32!ll end 4~0. one instruction can provide the NEXT Eo'[" One fOR a'tll.cement. Be careful that you list the NEXT variables in 110" I IIlXll ordllf. though. to ".void c rnased loops.
huu ts jU._st a ud.elay Leop" that 8ives you a moment to admire one b 'Con: th.e next nne begins. Each t1me line 48(il sends the compu~"r k toth ... HeR oomtrolld in ll1le 12G. HGF. clea,stile 6<:reen for the nexc
Ilh~
['P~II

I I.U'
lin'

sa
l(lll

IIOME:
VIAS

R.DI

24 : REM

CLEAR THE .EXT AREA MOirE CIIRSOR TO BOTIOM

It",
,111
I"

IU.'14H'U,.-

LINE II'" bnelr. ~D 'programming, stop t. ~yp~

120
14G

1611
ISII

2i11l
2211 26{1
Z8!1

A - RND(1) * 279 ,REM PICK AN X FOR "CE.NTBR" B .. RHD (I) 159 ;. REM PICI< A 'f. FOR "CENTER" U .. (gND(1)* 4} + 2, RI1l'1 PICK A snp SIZE HTAB 15 PRLNT "STEPPINC6Y n, 1%,

HGR,

REM SET HtCH-RESOLUTION

GRAPHICS HODE

the pattern

by t'Yp1.ng

*

"lui t ln-n II,.IU'

1',111 Y<H[ h!.nk of w"ySto L
~'''II

FOR X
S"

&

!J TO VB

STEP

U

; RfJ1

STEP

lHRl) X VA[.UES

241,liFOR

tlCOLOII"
REM IIPLOT
NE)IT

2 LINES, FROM X Al'ID x.+! REM FIRST UNE BLACK, HEXT WHITE DRAW l.INE TIIROllGH"CENTER" 10 orpos ITE SIDE TO L : REM

II

change the progrlun? After ~"'.~ett" rocorder or dhk. try making the value " nnJj,'m! y. Try d ""wing U rs t. "hit e , then black Une".

SAVE1ngthis version of HeOl.OR change Of' Dilly "hi te lilies.

on

3

*

S;

311\1
32(1

X-+5.Il
5, X

TO A,.l1 TO 279-X-S,

159

26

27

28

SYNTACTIC DEFINITIONS AND ABBREVIATIONS
(For an alph.s·betic list of these d'"fin1tions, see Appe'nd:l;><N)

fUUliu

lhe followi"!! d,efini~ions \lSe mecasy",bols such as ( lind \ -- chllrllcU'rs used to un.ambiguously indicllte at rue t.u res or relati<>"shl ps in AP.FLESOF'I '. lhe metasymbols are not pllrt of API'LESCF1. In additi,on to the true merasymbols, the special symbol ,~ indicates the begi!HI.ing of a complete o[ pa ttial definition of the ten. tha t is to the leh o,f :
B

symb 01 used to' separate ,,_lternatives (note: a" item may also be defined separately for each alternative) :'.. met"symbols used to enc lose material which is optional mecasY!!lbols used to enclose !lin rer ia1 whlch limy be ((,peated ... metasY!!lbol used to eoclose !!lateri,;! "hoae value is to be used:el1e value of .;<
...

",I'. "a

,·letterl(letterjdigit}) A name mily be up to 238 characters in length. When dist1nguisl>ing one name Erom another, APPL.ESOFT tgno.es any ~lphanumerlc characters .. her th .. first cwo. /lPPLESOFT does not distinguish bet'"''''''' th.e n8""9 GOOD4LITTLE and 'GOLDRIJSH. HoY""er , e "en tit .. ignored portion of II naae "'Ullt no t COli tain a "pecial, a quote (") or sny of Al'l'LESOFT's "r "served words." (Se" the Appendix A fo r a lis t of theae re"e rved "ords and eommen es on exceptions to thlo rule.}

I'll! "I~ r
,. (+I-Hdig1t} Integers ",\lst b e 1n the ung,", -32161 to .32767_ \IlHln eonvezt t.ng nOn-lncegets into 1ntegers, IIPP..L.ESO.FT usually ""'.y be cOrlllld.ered to cruncac e ~lIe non-integer to the nex r smaller 1" reSeI'. How""e., rhis is no t "Nite true 1n the l1rnj e as til non-integer approaches the ""xt larg"[ integer. Fo.t j ,,9 t"nce"

' .. ",,,[asymbol ,"" tas)' .. bo 1

~itten

"hicb

\x\

indicaees

a r",'1ui red

space

,-11111I<l}l\I-

11%-123.999 999 959 999
PRINT A% 113

lcwer-C:Q"se le't

;. alblcidleJflglhliIJlk]1]m]n[ojplqlcls1clulvlwlxJylz
Lener

t.eC

B%-12J.999 PRINT 11% L24 D%"12345.999 PRINT 1)% 1234~

999 96

ml'.easymbol ... 10wer-CSBe digit

C%-12345.999 PUNT C% 12345

995 999

996

.• 1[21314151617181910
[digit)
~-

(:Sp.nees a dded for easier An lIrrllY In [eget occupies l ill I 'IIa\t.l r v,O,rt.llble
n£ll!H.l'l

n,ading) 2 by ees

(16

b 1U}

1n memory.

m_etaname :- {metasymbol}

name "ar1able, but. to an intege.r_

A real
1\

",,,t!l9ymb01
special ;special

... y be stored as an int,eger ~PL&SOn: f1 n t (;onverts the real

: _ a: ·s1ng,le digit 6'11111101 used special by

c:oncate'c8I:cd Al'PL1!SOFT 11

to a me'toname

.'"' '1+ I-Hdigir}{.

Ii !-J[{d.lg1tl].

;-

IllISI%I'I'I(I)I"I;i-'I-I@I+I:I'1I!1>I.j<j,[II-I'.' Conl:r,,,l "haraeters (chtl(acters which

are typed while holding d.own the CTRI. key) and the null charue ter arc also spec bIB. APPLESOPT ua es t,he right bra,ckec ( I ) only for the pro",pc charnceer io '!Ch1& document it is used as a !!leeasymbol.

(digit) J IE H-!-ldigh [digit)] [{digitl] [E[+I-]digitId1gftlJ fht' letter E,. as used dn reill number notation {II form of "ac1e"t1£1c notation"), .~"ndu fat "axpcnenr ;" Ie 1,ssharthal\d for *10Ten is raised to the po"er of the 'lllmbor on B' II right, and the number on E's laft 1s multiplied by the resul~. r ea.Ls mUBt be in the 'range -H138 I,E31:1 or you r .takehe 10vERaOw ERROR message. USing addition Or subtraction. you msy be IIble co I!.merau. numbers lIS 1 arge as I. 71038 wi th ou t rcceiving this message.

;

In fII'PU:SOf'l,

to

letter

._ AI8IC!DIEjF1GIHIIIJIKILIMINIOIPIQIRISITIUIVIWIXjYIZ

ch!l~acte~ : .. Ie tte r I digl t I specis.l alphanumeric character . : .. lener I digit

31

30

A real whose

absolute

value

is less than about

.(.4

2.9388£-39

will be converted

by APPLESOFT

~o zero.

APPL-ESOFT recognizes the following as real s when presented by themselves, and evaluates them as zero: +, .E +. E -.E .E+ .E+.£+..1>+ -.F.+ -.ETherefore, the anay elemen
t

r n18 are printed with up [0 [en digits, including the "e~Q Immediatl'ly to the right of the decimal poin c. This is the only excep c ion to the lLmit of

1(.4(J \1I(I~ 0(1(15 to .~ 999 999 999

,,'l!,,' printed

digits, excluding

the exponent.

M(.)

1s the aame as ~1(Il)

In addition to the abbreviated " e"Is listed above, the f0110"1n.& are recognized as r ea ls and evaluated as zeto when used as numeric responses to INPUT or as numeric elements of DATA:

If you attempt to use a number with ,I Iglt9, such as 21 J.llllllllllllllllllllllllllLlllllllll t.hen th ",.eesage

more eba.n 38

+

E E-

E+

+E+

+E
-1£-

-E -E+

space -E-

The GET ins r ruc tion eva.l.ua ees all of [he s1.n81echaracter reals in the abov@ lists as zero.

Leading zeros, however, are ignored. If the fi,st d tgt is a one, and th., second digit is less than ,,~ equal to six, numbers with 39 digits may be u~ d without getting an error mesaage. " r.eal occupies 5 bytes (411 bits) in memory.

2Il.g~0~(I~~~~~~(I~~0e0\11000~0\11~\1I~\1I~0~000g0

lOVER I'I.OW ERROR printed. even if the number is clearly wi thin th range -LE38 through U;38. ThiS is true even [ '" fl[ of the digits are t."iling zeroes, 9-5 in

When pr in Ing a -real number, A.PPLESOFT will show at moBt nine digil:s (see exc"ption, belo"), exc:luding the expcnen t (if ..ny). IIny funher digits are rounded off. To the left of the decimal point, any zeroS preceding the leftmost non-zero digit are not printed. To the right of he decimal pOint, any zeros following the rightmost non-zero digit arc not printed. 1f there are no non-zero d~gits to the right of the deCimal pOint, the decimal point Is not printed.

,,,,I

yn,r"ble I .... nutti

name

H II h,q, lie vn r.lable nv r
IV

r
I" Imme J 08

mel AI I simple variables occupy 7 bytes in memory. 2 bytes fot the nam~ Dnd S bytes for the real or inte8e~ value.

@
Rounding can be curious: paINT 99 999 999.9 99 999 999.9 PRtN'I 99 999 999. 9(1 HI\1I(111(1 (I~1l PRINT

.1'1 I l

ta

l

t.1r

,. ·1(1)1-1-1

1-»1<1/1*1,1;

I:

A nsme does not have to be aeparated ftom a pre d lng or following rese.ved vc rd by any ,,(these delimiters.

" II Ioill. II C! ()1I1!~a tor
(1)

ll.Lll

11. ILL

LJI 5

LLI

~511

\liP
r II hl11Mf c logicol operator
,101'

PinNT Il.Lll 111 451 9 !l.11L III 4 (Spaces added for eosier 1f a equal real That reading)

real's abaolute value 1s greater than or to .111 and lOBS than 999 999 999.2, the Ls pr tnr.ed in [bed-pOint notntion. is, no exponent is displnyed. In the range

,. ANDIORI-I>I<I<>I><I>·I~>I<·la< ~OT is not included here On purpose.
!lp
'l'H

,·op 01' '. nop[alop

32

33

arithmetic expression := ae.xpr ~• .avnr aexpr

._ soxpr sop sexpr :- avar I~ea.1linteger ;B (ae"prJ If parentheses are nested more than 36 levels deap , the 10IIT OP MEMORY ERROR occurs. ;- [+I-INOT]aexpr Unary NOT appears here, along with unary + and - • .- """pr op ae"pr
II~

I strin,g

r I "l> logicnl :- s l.op

operator

.1"1l

subscript. ._ (8expII(.

.• 8 xpr slOp sexpr
v

"expr}]) The _ximum number of dimensions is 89, although in pr ac t Lce tbis will be l.1m1ted by tbe extent of memory available. aexp r must be positi~e, and in use it is converted to an inteser.

l... bl...
=vr

tinY

;. avnr [svar
H."lri"lltl (on

ava r "expr

._ avar subgcrip~

.•

e.l<pr

._ aVer subscript
,. D

xpe Ise xl' r

literal .- [{character»)
string

PI""'pl ,_I chnracter

:- "[(character)]"
;-

The righ~
18 ready

bracket (I) is displayed to acc.ept. a.nother;- command. "RESET"

when APPLESOP!

A string occupies 1 byte (S bits) for its length, 2 bytes for its location pointer, and I byte for each character in the steiog. "[{character)] return This form of the atring can appear only at the end of a 11ne.
lin

I"

.1101"(

;- .. press of the key marked
Me

null

s~ring
:_

;. II prells of the key marked "ESC"
'Ijtu'rn

.tring variable
;na.meS

name
rid

-, n. press

cf

che key ma eked "RETURN" che fo110"10&

sering vor1ab1e.
: _ svar

, .. hold down the key marked "C11lL" while named key 1s pressed.
II,,· number

svar ;- name$lname$ 8ubscript the location pointer and variable n8me each occupy 2 byces 1n melllory. The length and each string character occupy une by~e. scr.1"g operator
:sop
801'

:. l:lnenum
ttlle.lU",

:- (digit) Line numbers musr be in the range" or a ?SY'NTAX ERROR messas" r"sul~8.
11n~

to 63999

:. +

st. ins express1(,"
:se.xpr

._ I1n(\nu", ({instruction:)] instruction re turo " line may hove up to 239 ~haracter". This ineludil8 all "paces typed by the user, but does not include spaces added by APPLESOFT in formatting the 11ne.

34

35

RULES FOR EVALUATING EXPRESSIONS
Oparators are listed vertically in order of ...xecut Ion , from the hig,hest priority (parentheseal to the l"",,,st ptiority (OR). Opetatol:s listed on uhe sa"" line are of the sam.. priority. Operators of the Same priority in an
expression are ,exec"ted from le'ft to right.

+ - NOT

unaty

operators

*
:>

I

+< >- <,_ -> -< <> >< ..

AND OR

CONVERSIONO,F

TYPES

Wh"" "n in ["set and a real are both pres,," t in a calcula tLon, a 11 numbers arc converted to real s before ~he "alcula tion takes place. The resul es a:~e converted to theari'th ...~tic type (integer or real) of the fInal variable to whi"h they at" Ilss,igned. Fllnctions whicn are defined on a given arithmetic 'type will convert ar'gu",eots of another type, Co the type. fpr· which they an' d,eE.ifl"d. St rings and II rt th"",Uc types cannot be mixed. Each can be Con... r ted to the other by Ellnet ions provided e for' the purpose-

EXE,CUTION MODES
imm Some tns t rue tions ,may he used in immed race-execucfcn mod" (i""") 1n APPLESOF!. In iallll"d1s.ce-elleeu t Lon mode, an 1n8([u"t100 must be typed without a line "umber. When the RETUI\N key 15 pressed" the instruction is i".l,,,diac,elyc.~ecut,,d.

def

loatn,ctiona used in de.fe.ned- .. "ecutlan ...ode (deE) musC appear i" a line tha t begin. wi th a UnO' number. When. tho. RETUllN key is pressed. APPLESOFT stares tlte numbered lioe for later usc. In6·t'ru~ tiQns in deferred-e.ecution mode are exacu ted ollly "'hen tltei r line of II pr,ogram is Rml,.

36

LOAD imm & def SAVE i!!llll /; deE WAD SAVE These WAD .. program irolD a cassette rape and SAVE 8 program on a cassette tape, respectively. There is no prompt .. ing message or other s1gnlll iSllued by these commands; the user mus e have the cass ..·tte tape recorder runm.ng in the proper lDode (play or record) ...ien the command is executed. t LOAD and SAV'Bdo not verify that tbe recorder 1s 1n tbe proper mOde or even that tbe recorder is present. !loth commands sound a "beep" to signal the beginning and the end of recordings. Prog.ra.m """"ution current program tape. Only reset can continues ,!tfter " SAllE operation, but" LOAD d.elet .. s the when it beginB read.ing new Lnformation from the "B.SSette

1'1''' rO. If lineDum lNYNl'AX ERROR

is

greater in

than which on the

63999. line otber

the

message

"~I"nrll.
In I .... edie

You aea not

told

the er ro r occurred.
hand,
these.

cKecution mode, I UN IIIH' • J) S l'A T EI1E:NTJ>RROR IN
lIf1rl

">0<,,

two m.eaBases

become

I!lY14tA)! I'.RWOR IN ><JO(X .. Ilo' .' x"xx can be various

Ii""

numbers.

usually program. executed.

above any

65~llg. subsequent portion of

il RUN 1
ll,

tal'"

d1

u cd in .. lmmediace-execution n te- xecur ton program is not

1I

•df
.'"
t

tllU
interrupt " "LOADor a SAVE. tlrl.

r,

reserved "'o~d LOAD or SAVE is used aa the first characters of a variable sam", tbe reserved-word command may be executed before any 1SYN1:AX ERROR message is given. The 8 ra [emen t SAIIEltING .. !> causes APPLESOFl to try SAVE1ng the current progrs.m. You Can wait for the aecond "beep" (and the ?SYNTAX ERRORmessage) or press reset. 'rhe statement LOAOtOJOY .. 47 hangs ehe 9ysteID, ..,h:1l" APPLESOFT deletes the curt!!nt ind"finite~y .for a program fto," the ca,8sette reeoed"r. reset can you regs in control of the computer.

If tbe

III

.. d'( tlTllll only 1m only I.. dr ...

I

1m' ~m

• pi

tull"

•.. I~ "l
"1111'

program and \oIaits Only by pre.sing

to cease execution, .. nd returns control of 8 II program It prints the message use r , 1\I(Io,AKIN Ltnencm 1'11,,'1' lIn num 1s !Che line number of the statement which executed

, '''"J,"Lt

'"I

the

r to the

the STOP.
the user.

INI)

ts
NEW 1,.,.. 1. def

program printed.

to cease

execution,

and

return!l

control

to

No p·arameters.

Deletes

current

program

and

all

variables.

• 1,1 I: Ii OJ an effect equivolent to the insertion of a STOP statement I",... "lIst"l), .uter tne .tatem.ent that is currently being executed. c tIL C • "" b" "u"d to tn [ e rrup t a LIST:l ng. ! e c en also be used to in t,,[rup t an IKl'll'r. b"c only if it is the first char acr er entered. The INPUT is not iliti rllp d until l""eturn is presse:d . lOpS any APPLESOFl program 0'[ command unconditionally and l ....."dlately. The program 1.s not lost. but some prograM pointers and stacks '[" L 't d. This comlDlLodleaves you in the system OIOnito1: program, as Indl .lod by the monit"e's prompt character ( To n:turll to APPLESOFT lollI heut destroying the current stored program, type c t r L C rllturn.
•• • , I

RillI
RUN

him

6d

r

[linenuml

* ).

Clears a~l variables, pOinters, and .tacks and begins e""cution at the line number indicated by 11ne""",. If linenum is nOt indicated, RUN beghl8 at the lowast numbered line in the prosram. or returns control to the user if there is nO prosram in memory. In deferred execution mode. if lin."u", the program, or if lin ..num ia negative, 1UNDEF'D STATEMENTERROR is given but there then the message ia no such line in

cut ten bas been halted by StOP, END or c cd C. the CONT execur t cn to resume at the next instruction -- not the n x~ Hnnumb r , Koehing f.s cleared. If there is" no halted program, then OIfT hll8 nO effect, ALter reset ctIl C return the program may not CONTinue LO xecu e properly, since some program pointers and stack,s will have been I ored.
1ft l<

II

I) 081

""",,,,,,nd causes

38

39

If

an

INPllt

statement

is,

halted

by

c

t

r

L C, an attempt

'to

CONTi!!ue

execut

Lcn

'Ill'

I ..

Ir

del

r.aults in a ?S:tNTAX ERROR IN 11nenu", message, .me,e linenullI is s ta temellt '.

~he Une

nU.mber of

the

line

oo[)taini,ng

the

UU'IJT fiOIlE ato]:"", an e.iSht bit quantity, the binary equivalent of the decima,l v"lu\aexp~2,\, into the location ",hose addtesa .18 given by \a,,><prl \. The [nns' <>f \8""1'<2\ must be from I' through 2S5; that of \"""prl.\ muSt be from 4S:SJS through 65535. Real" az e convened to int'eS,ers befot'e ex'ecution.
Out
0·[1

Executing, GONT will result in the ?CA!l'l CONTINUE ERROR ct:es5a:ge 1f,t after the progr-n.m"-:5, xecut Lon halt.B ~ the useX' e a) modifies 0 ~ d,.le tea any p"ogn.m 11neb) attempts any operation .h.at <esuIts in an error measageHo"."er. program variables ~ be changed USing h[llled1ste-execution comaands , as long as no er rcr m.enages, are in.curred.

eange

'values

cause

eho

me:ss"ag,e

11[..1.I-1<'AI. QUAN:TIT Y ERROR to b~ p,tin'ted" \Il xpr2\ wU.I be successfully s tared only if tb.e "pprop,riate receiving, ho'rdwor .. (memory" o'r a suitable output device) is present at the .ddreas ~1.';Jc I,fted by \ael<prl \" \aexpr.2\ will not be succeaafu l Iy stored (I't ,,'m-recep t1 v. a.ddresses such !IS the. MDn:! to" ROMs r unused Input lOu t puc Il",rt'll.

If DEL is used in " defen:ed exetut.ian statement, the deleted and then program execut Lcn halts. An attempt these circumstances w111 ~.. use the' ?CAN'T CONTINUE ERROR rnes.sa.ge~ If

$

specified l.ines are eo use COm: unde,J;'

°

CONT is used in " deferred ...... cuti,on statement, the prog~am'e ",,,,,cution halted at that statement. but control of the "o",pucer 1" .!!££ returned to the ""e.t. The user "an regain tontrol of the ecmput er by 1,sauing " c tr 1 C ceeneand , but an at remp t <0 C:O!IT1nue program axecu t ion In the 'next statement merely relinquishes control to the halted program again.

i,.

I1l:8"n"rn,1., this meanstha t \aexpri \ ,,11"'1'0lOOX 1s <letermined by the amount Ill"tU11[!<I., on an ArYL.S II ...ith 16K of hilI' 32K of .",mory, OIiI,. j II 32158; and h 49152.

w111 be 1n the

renge II rough !no , x of memory 1n the computer. For memory , max is 16384. If the APPLE 11 .i f t he APPLE 11 has ~ 81<:of memory, max
to the may 31 ter the A!'PLESOFT.

tn

li"nl' OJ mory locations contain information whIch isn"cessar.y I !Jt"::li'onlng of compute:r sys cam, A POKE into these locations '11"'rtHlan Clf tll,e sys,te.," or of your program, or it may e Icbber

1'kACE t""" & del ~'lYnIo.CE dd

i_"

WIIIT n'-""'pd, hJ hJ'W'u us er
1111

oexpr2 to in:set"t

f,

a.expr3] a cond t r tcna l pause int.o a progr,am·. Only r eae c can

TRACE NOTRACE TRACE sura a. debug mode that displays tim lin" nu",ber of each state.ment as it 1s e.xecuted. When the proSt .... also prints on the scree" TRACEs may be dlSplayed in a" unexp ec ted fashion 0 r Dverwr tt een. NOTRACEtorns ·0£f rhe 'l'IlACE de bugQ>Ode.. On"" set, TRACE is nOt cucned of f by RijN, CLf.IlR. NEW, DEl. 0 r .ese t: reaa t off TRACE. (and elimin.otes .llny atnr ed progr'''lJ)l,.

'rr"pt

0

WALT.

c t r l, B turnS

\""'''l>r I \ La the address of a memory l eca t ion; L ~ mu" t be in thcrangc -65535 I II r<lUllh ,65535 to I1void d,,, 111,LF;CAL qUANT Lty ER.ROR ""'''lIose. In practice •. \oe~pd \, is "Gu.ally limited [.0 the range of nddn,s&es ,.". r{".ponding to loceti,ons at wh.tch vslid meMory devices exist, from Il I h~<lUgl' rhe .... "tlllum value Eor HUu!lM': in yourCDlDl'uter. See IHMEM: and POKE torroor dctails" Equivalent pos1theand negntv!! addresses may be used. \"I'XIII 2 \ an'" \ aexpr 3 \ must be :I nthe range "''' IT 1,6 execuend, the8e values are converted ~ rh tough 255. deed mal. When to binary numbers in the range

II· H"~oullh
PEEK

(ae xpr )
the. contents, J contains in dadlllal, of the byte at address cxam:p-les- of how to use PEEK. \aexpr\.

t iu n u.

Returns Appendix

lIexpr L ond a(!~pr Z are a"pec.1Hed, each of the etsh ~b tea in the of location \"e"prl \ i8 ANDed wi th the CQ[f""panding bh in I II... bl,nary equivalent of \lIexpr2.\. For each bit. t'h:! .. gives a zero unless ho[h of the "o:rresponding bits <Ire high (l). If the I'eS" 1 ea of this process 1f anI),

hlnnry ,contGnts

40

41

are eight zeros, then the test is repeated. If any result is non-zero (which means at le,ast one high (1) bit in \aexpr2 \ was matched by a corresponding high (1) bit at location \aexprl\), the WAIT is completed aod the APPLESOFT program resumes execution at the !lext instruction. WAIT aexprl, 7 causes th" program to pause unti 1 a e least one of the til ree rightmost bit,s at Lccar iea \.exprl \ is high (l). WAH aexur I, II causes the program to pause forever.
If all thr .... parameters are specified, then WAIT pe rfo rma as follow6' f li6 , each bit in the binary contents of location \aexpel\ is XORed with the corresponding bit in the binary equivalent of \aexpr3\. A high (1) bit 0 \sexp.-3\ gives a result that is the ~ of the corresponding bit at location \aexpri \ (a 1 bee om .. a !ol; a {,1 becomes a I). s A low (~) bit in \aexpr3\ gives a result that is the same as the corresponding bit at location \aexprl\. IE \aexpr3\ is ju.st zero, the XOR portioo does nothing.

This program pauses until ApP'ndix K) is ~: l(j~ POKE -16368,

yOu type any character

whose ASCII
(HIGH BIT)

code

(see

I [~ WA11-16384, l.28 , REM. WA.IT UNTIL HIGI! lin: IS ONE. I. IS flEM PAUSE SOM'E HOllE UNTIL KE't STRUCK IS EVEN. 12" WAlt -16384, 1, 1 : REM WAlT UNTIL LOll BIT IS ZERO. 1311 PR lNT "EVEN" 14(1 GO'fO lPIJ

HIS 1ll>H PAUSE UN1:IL KEYBOARD STROBE IS SET BY ANY KEY.

II :

lt~!

RESET KEYBOARD STROBE

("All

I""" l> d f

CALL aexpr

Second, each result is ANDed with the equivalent of \aexpr2\. If the final repested. Tf any yesult is non-zero, the APPLESOFT program continues at the

corresponding bit in the binary results are eight zeroa, the test i.ll 'the WAIT 1s <o",pleted and "xecution of next instruction,

execution of whose decimal address
Causes

0

machine-language subroutine is specified by \aexpr\.

at

the memory location

Another way to look at WAIT: tbe object is to test the contents of location \sex1'rl\ to see when !!!!1. ~ of c.e rra.f.n bits i. high (l, or on) or !!!!.l'. one of certain other bits 1s low (~. or off). Sach of ~he eight bita in the binary equivalent of \aexpr2\ indicates whether you are interested in the correspollding b1,t at location \ae.xprl \' 1 "",,,ns you're interested, r.! meanS igno"te tbat bit. Each of the eight bits in th.. binary equivalent of \ae><pr3\ indicates which state you are WAITing for the corresponding bit in location \aexprl\ to be in: 1 means the bit ",ust be low, ~ ro means the bit must be h1gh. If.!!.!!:l. of the bits in wldch you have indicated intere,st (by s 1 in the conespondin,g bit of \aexpr2\) tn.atche. the state you specified for that bit (hy the corresponding bit of \aexpr3\) the WAIT is over. If ae><pr3 is omitted, its default value is zero. 'For instance: WAIT aexprl, 255, 0 WAIT aexprl, means pause un til a t least at 10cstion \aexprl\ one of the is high.

\aexl'c\ must be in ~h"rang" -65535 through 65;;35 or the m.e""Sage 11 1.LOOAL QUANTITY ElUlOII. Is displayed. I"n practice, \sexpr\ ;Ls usually limited to the rans" of addresses for which valid memory devices exist, from G through the maximum ""lYe for "!.HEM, Ln your computer. See IlIMEM, Hod POKE for mor .. de eaLls .

Il!quiva!eDtpositLv .. and negative
Lm.tance, "CALL -936" J contsins and

addresses

may

be used

"CALL 646r.!iJ" are

identical.

interchangeably.

For

AppendIx

examples

of the use of CALL.

'IiMtH:

1""""

del

Sets it

the or

8 bits

program,

of the highest ",. ory IDeation .m avaUable to " BtI.SrC including Variables. It i. used to protect the are" of memory above dato, graphics Dr machine language routines. -65535 may nOt

addrass

255

Identical

to the above, in operation.

WAIT aexpr l, 255, 255 mesns pause until at least one of the 8 bits at location \aexprl\ is low.
WAIT aexprl, I, 1

\aexpr\ muat be i.n the range 1ILLECAL QUANtITY ERROR
massage. However, programs

through 65535,
execute

inclusive.

to avoid the up

reliably

menns pause until the rightmost bit at location \.. xpel\ is low, regardless e of the states.of the other bit •. m.eans pause un tl1 either the r igh cmost bit Bt location \aexpel\ 1, high. Dr the next-to-rightmost bit 1s low, or both conditions exist.

appropriate .. emoey hardware to and including \aexpr\.

ae the locations

specified

unless ~here is by all addresses

WAIT aexprl,

3, 2

In general, the maximum value of aaxp r "is determined by the amount; of memory in the computer. For instonce, on an APPLE II with 16K of memory \aexpr\ would be 16384 or less. U the A,PPLE n has 32K of memory, \oexpr\ could be no high as 32768; and if the APPLE II hss ASK of memory. \aexpr\ could be as high 110 49152. NormaUy, APPLESOFT automa.tically SMS IHMl>H: to the higheot memory address n,v~Uable on the user's eempue er , .. en tlPPLESOFT is first invoked. h

42

43

The current [decimal).

value of IIIM.ll1: is To see the current TPEEK(L1S)

stored value

in memory locations of B]HEM:, type

ll6

and

US

PRINT

PEEK(L16)*256

If HIHEM: se t s II highee t memory address which is lower LOMEM:, or .. ieh does not leave enough h memory available run, the
1.oUT .oF MWORY ERROR

than t.hB t se t by
fo r the pr,ogrsm

Oncl! ser , unless it ia first reset by one of tbe above commands, LO~lEM: can b s t to a neW value only if the new value is higher (in memory) than the oLd value. An IIttempt to set a lower LOM£M: thao the vslue still in effe~t gives ehe
10lIT OF HEHOR,{ EllROR

to

m's .. se. a

ChQnglnB
portions eonlinue

is given.

tOMEM, during he course o.E II program may cause cer t a rn stacks of the program to be unavailable, so that the program will not to execute properly.

or

\ae"pI\ may be in the range
range -65535 increasing be used interchangeably.

I)

increasing
Equivalent

to -I.

to 65535, or in the equivalent positive and negative values may

EqUivalent

positive

and n"gativ"

addresses

may be used illterchangeably.

HlMEM: is not reset hy CLeAR. RUN, NEW, DeL, chang Lng or adding a prog'ram line, or reset. HIMEM: II reset by reset ctrl B return, which alao eraSea any stored program.

USR (nexp e ) Tlrh ~u"ctioll passes

\sel\pr\ to a mach Ine=Language evalua ted and put
SA3), and a JSR

subroutine.

UlItEM:
L.oMEM:

iTIllll I. del lIe>;pr

Sets the
This

address of the lowest memory loea~1on available to II BASIC pTogram. 18 u"Wllly [he address of the starting m.em.ory Loc.a t Len for the first BASIC variable. Normally, APPLESOf1.' automatically ae rs LOMI;}!: to the end of the curre"t program, before executing the program. This command allows protection of variables from high-resolution graphics in computers with

in'to the floating point ,,,,clirnulato[ to location $~A Ls performed. Locations ~~A through $~C must contain " JHP to the beginning locatlon of ·he IDachine-langusge subroutine. Th.. return va.Lue for the fUnction Ls plac~d in ~he floating point ac~umulator.

The argume"t ae xp r' is (locations $9D through

To obtain B 2-byte integer from the value your subrouc'tne should do a JSR to $El(!C.
w11.1 be 1n 10cat100s $A0 (high-orde.

large amounta of memory.
\aexpr\

in the floating-point Upon rerum, the byte) and SAL (low-order

ac cumu.La tor. intege.r value
byte).

be in the range -65535 through lILLEGAL QUANTIT'i ERROR message. Liowever. 1f LOMEM: is set higher the message
must

65535,
than the

inclusive, current

to vallie

ovoid the
of

To convert

LiIMEM:,

an integer result to ita floating-point equivalent, so that the function can return that value, place the t"o-byte integer in registers A (h.Lgh-order byte) and 't (low-order byte). Then do 0 JSR to SE2F2. Upon r turn, the floating-pOint va Lua \01111 be in the .floating-point accumulator.

?OlIT OP MEMORY ERROR is displayed. This means that \ael<pr\ ~ be lower thOn the value that can be set by LiIMEM: (Sc.e HLMEM: for II discussion

maximum
of ita

Ta [Qturn
m,,>;imum fonnat; J reset

ta APPL"SOFT,

do an RTS. the USR fuoctioLl, just to show you the

value. )
If LO~fDI' is set 10" .. r occupied by the current the
10UT OF MEMOR,{ ~S58g" is "gain

Ilcre ia a trivial

program us tng

thall the operating

address of che highest memory Loc ae Lon system (plus any current. stored program.).

• (!A,4C ~(! 1j13 return

*
*

ERROR
30

of about

displayed. This imposes 2~Sl for fir~are APPLESOFT.

absolute

lower

limit

on \ael<pr\

03(1(1:6(1 return ctrl C return I PRINT USR(8)"3 24

LOMEl'I: 1s reset WIlEN, is reset ls not reset by

by NI!I,I. OKL. and by adding by reset ctrl B, which also RUN, reset ct[l C return or stored value

Ot

changing a program line. deletes any s te red program. reset 0G return.

It

The current value of 'LOMEM:i8 (decimal). To Be" the cur rent PRIll! PEEK(l1jl6)"Z56 T l'EEK{L\l5)

in memory locations oE LOMEN:, type

lll6 and l\il5

At location $~A, We put a JMP (code 4C) to location S3g~ (low-ordar byte first, then high-order byte). At location $3\1~. we put an RTS (code 6~). Back tn APPLESOI'T, when USR(8) was encouncend ~he argument 8 waS placed in tl!e accueu La tor, the HOni Ot did .. JSR to location $ilA where it found s J}IP to $3(1(1. [n $3\1(1 it found "n RTS wh1cheent it back to IIPPLESOFT. The vlllu", returned "8.9 just the origina] va lue 8 in the ac cumu Ia trrr , which APT'LESOF-T ~hen multiplied by J to get 24.

44

45

I.. 1ST LIST LIST

1mm 6 de f [linenuml) [linenu",! )
[{,

llnenum2J linenu.m2]

DEI.

fa.. 6 def

DEl. linenuml

,

11,neDlLm2

If neither l1nenum1 nor linenum2 1& present, \iIi.[h or without a delimitor, tbe "Dtlre program :is displayed on the screen. If li"enurnl 18 pres nt without II de.limiter, Or 11 I1nenuml~linenum2, then just the' lIne numb "'nd linenuml is displayed. If linenuml and a delimiter are present, then hI' program is listed from [he li.ne nllmbered ll"enumi through the end. Hn deli.miter and line.num2 are prese.nt, the" the program is listed fl:om the beginning through the lin" number"d lin"""012. If linenuml, a delim1t·(: onll linenum2 are all present, then the program Ls listed from the Li.ne numbes- d linenum1 tluougb the 11"e numbered lioeoum2, inclusive. When mare than one 11ne i. [0 be listed, if the line numbered l'in numl. in the LIST statement does not appear in the program, the LIST ~ommand .,111 U80 the next. grea.ter line numhe r that does "pp"ar in the program. [f th Un· numbered Uneuum2 in the I.tST stateu.ent does not appear in the progrom, ch LIST eornmand vi.ll use eIle next smaller line number that does appear in til program. These all LIST the LIST I) LIST LIST lists l1nenum, from the entire

DEL d"letes r he range of lines from Linenuml to linenum2, inclUSive. If I1n mImi is nat an e~isti"g program Ltne numbet:, the nexc greater line numbex in the prog~am 1s used ill lieu of linenuml; if linenum2 is not an ><l&t1ng program 11.ne Dumber, the next smaller program line number is used.
t( you don't b '10\01:

fOllow

the

usual

format,

DEL'"

pe.rforman~"e

varies

as

Lndf c a t e d ~

DEI. DEL DEL ,b

1SYNTAX ERROR ?SYNTAX ERROR

? SYNTA.X ERROR ?SYNTAXERROR deletes line ~ero, regardless of the value

I, H
.. ith

I)

program' LIST

DEL
0

-al.b) ~,b

1,1-)
lin"llulll

0

0
l1.ne line number through the end of the pcog r ..m.

DEL

of b,

OEL 1, -b

LIST , Q lists the entire ?SYNTAX ERROR message.

ignored, even if number is ~ero. ?5YNTAX ERROR if

the

program's

smalleD t 1 tne

program,

then

give.8

the

DEL a,-b

a is greater line line

than the the and

APPL£SOFT "tokenizes" your progr ..", lines be!oTe storing them, removi"g unnecessary spaces in the process_ When LISTing, APPLESOF'r "reconstitutes" the tokeDued program lines, adding spaces, a~cording to its own rule... example, 19 C-+S/-&: B-S becomes L~ C ~ + 5 I - 6,8 ~ - 5 when 1..1STed.

program's smallest program's smallest a is one.

number, unless number is zero

For

DEL B,-b
DEL 8,-b

ignored program ignored than or

if a is not
line is line

zero and the "umber zero.

only

U

a is
l, to

11ne number.
DEL a[, J ignored. 19nored than b.

equa

not zero lind if .a is less the program'" smallest

LIST uses a variable line width and var Leua indentations. Th1& can b,,- .. problem ",hen),ou are trying to edit o"r copy a LISTed instruction. to .force LIST to abandon formatting with extra spaces, clear the screen and ",edu.ce the t ..xt ... ndow to Width 33 (tnaximum): t l'OKE 33,33

DEL

a,b

if

II

is

not

zero

and a 1. greater

aOME

Al'PLI!SOFT truncates .. line to 239 characters, then LlS! adds spaces liberally. So you can enter many "",era characters by leaving out spaces when typing _.- LIST adds them back. An attempt to copy your expanded statement from fhe ac ruen results in truncation to 239 characters aga.Ia , including the spaces added by LIST. LiSTing is aborted by ~trl C.

~

When used in "" ution.

deferred

execution, work in

DEL works th1s

~o
~q

de"~r.lbnd
~ ~

CONT will!!£!:.

S1tuation.

above,

then

h.slts

48

49

REM {ch .....aeterl"}
This serves cha~acters, The'Lr usual to allow including meanings to be inserted in a program. All statement separators and blanks may be included. are ig"nored. A REM is termina ted only by eet.u ... !. !

text of any sort

Note thn r tile ar ruc.tures of IlTAB and VTAB ar e not para.llel, in that !lTABs b·yond the right edge of the screen do not cause the ?ILLEGAL QUANTITY ERROR III 'sSAge, bu t cau.erhe cur-se r to j ump to the next lower 11ne and tab C(o Kpr-I)MOD 4~)+1.

Whe.n REMS ate listed, ho,", mAny spaces were

APPLESOFT inserts an extra space typed af rer REM by the user.

after

REM,

no matt Or

TAB (nc~pr VIAll 101m " d f TAB.!!!!!.!!l.be used in a PRINTstateIDent, and aexpr must be enclosed in pllrNlthcscs. TAB moves the cursor to the pOSition that is \aexpt\ printing pos t t tons from the laft margin of the te.xt wi.ndow if \aexpr\ is greater than h~ value of the current cursor position relative to the left margin. If \0"'1<1'1;\ is less chan the val"e of the eur ren r cursor position, then the f'ur80r ts not. move.d -- 'rAll never moves the cursor to the left (use HTAJl for [hlo). TAli mcrves the cursor beyond the rightmost limit of the text ~indow. the cu ~.or is moved to) the Le f [",os t l1mi t of t.he "ex t lower line in the. t ex t w~ndow. nnd spacing eODtinues h'om there.

VTAB aexp r Hoves the cursor to the line that is \aexpr\ lines do,",n on the top line 1s H.ne I; the bottom line is line 24. This state,.eat ".,,,lng the cursor either up or down, but never to the right or Arguments outside the range 1 to 24 cause the message ?ILLEGAL QUANTITY ERROR to appear. acreen. The may involve

left.

'Il'AB uses absolute mcves, [elativl! only to the. top and oott,OPl of tbe ~: it ignores the text \lindow. In grapl11Cs mode , VTAll will IOOve the cursor into the graphics area of the screen. t.f VTAB moves the cur sc r to line below the tellt window, all subsequent printing takes place on ths,'t 11ne.

a

TA8(~)puts

the

cursor

lnto

positlon

25&. 255, or the llIessage

\0 >cpr\ must be 1n the range 'I! LI,ECAL QUANTITY ERROR 1I~ p~118<lnted.

II through

,.,..R
1 HTAB sexpI Assume the line in whIch the cursor is located has 255 pOSitions, I through 255. Regardless of the taxt window Width you may have sat, pOSitions 1 through 4g arc on the current line, positions 41 through 8~ are 00 the next line down, and so on. HTAS move,s the cursor to the position that is \aexpI\ positions from the left edge of the current sc rean line. IiIAlI's moves are relative to the leEt margin of tbe text ,",indo,",. but independent of the line ,",id HTAB can move the cuese r OU tSide the rex t loti ndow. but only long enough to PRINT one character. To place the cursor in the leftmost position of the current line, U8e UIAH L.

pa <sed .r, Isporenthesis. as

a ."served

"0 rd only

if

the

next

non-space

eh. rile ter

is

a

I'OS

('xpr)

tn.

®

InAH ~ moves

the

cursor

co position

256. than 255, the message

R~lUr"8 he current hor120ntsl pos.Lt t on of the cur sor on the screen. r-e l nt.l va 1:0 he left hand. margin of the text 'lJindoW'. At: th~ left margin, 0 I~ r turned. Although expr is just there to hold ~he parentheses apart, it l eva Lua ted anyway, so it ",ust not be illegal. Anything which can be Illtcr,prctcd as a number, a string or IIvarisble name may be used for exp r , If xpr Is a set D characters which cannot be a variable name. the ~'h"ractcrs must be enclosed 1n quotation mark.s. Not· thllt for )-fTABand TAB positions are from G. Therefore POS(g) numbered from I, but fOr POS and

If \aexpr\ is negative Dr greater ?ILLEGAl. QUANTlTY ERROR is printed.

IlI'C th yOre numbered
I'll 1 liT TII,8(23); 22 to to

"'''"8CS

~lllwr SPC(23):
u BeS 2]

be printed.

POS(g)

"hile

be printed.

50

51

S PC i1m Ii def SPC (aeJ<p"C) Mu.st be "sed in ... PRINT statement, and aexpr ,""at be enclosed in parentheses. Introduces \aexpI\ spaces bet"een the item previously printed (or, by default. the left margin of the t"xt "'indow). lind the next item_tO be printed, if the SPC command concatenated wlth the items pr eceedang and folloWing, by juxtaposition or by intervening semi-co10n8. SPC(~) does not introduce \aexpr\ any space. must be in the range ~ to

~1I1' t1l.& (expI'l

6 def

PRE roturos the amount of memory (in bytes) still available to the uSer. You 1It9.)' somet.imes wind up with mOt'e. Plil!'lmo["y than YOll e)lpect~d ~ ainl!"'2 APP1.ESOFT stores duplicate strings only once. That 1s, if AS·"PIPP1N" and B$ .... P1Pp 1N" then the string "P1.PPIN" will be stored only cnce , 1f
fI

255, inclusive,
-

or

the

message tne form

the number of free memory bytes gotiv", oumber. Adding 65536 to r r ee bytes of memory.

exceeds 32767, FRE(sxpr) thia numbel: gives you the

returns actual

a number

of

?lLL£CAL QUANTITY~OR appears. However, one SPC(aexpr) PRINT SPC(250)SPC{139)SPC(255) and so on, to provide arbitrarily

con be concatenated
large positive spaces.

to ano che e in

Hate that .... hile IlTAB moves the cursor to an absolute screen position relative to the left margin of the te'){t windo"" SPC (aexpr ) moves the. cursor a given number of spaces away from tbe previously printed item. This ne .... position may be. any""ere in the text window. depending on the location of the previously printed item. causes spacing or line 1n the text

Spacing pri[ltlng window.

beyond the to resume

ri,ghtmost limit of the text wiodo,.. at the left edge of the next lower

When printing in tab fields, spacing may be .... ithin into another tab field, or it may occupy a ~ab field If \aexpr\
SPC is left is a real, it is converted ...ord only to if ao integer. the next

8

tab field
of its

0"'''.

or acroas

FRE(expr) Ietu:rns the number of bytoes remaining below the string storage "pace and above the numeric aI:ray and string pointeI: array space (see memory map in Appendix I). 1U}\fi!: can be Set as high as 65535, but if it is set b yond the highest RAM memory 10cat10n in your APP1.E, FRE "",y return a rother meaningless number exceeding the memory capacity of the computer. (See IllMfIol: and .POKE fOI a discussion of m,emory limits.) W'hn the contents of a Btring are changed dUl:ing the course of a program, {c. 8' "$ ",hi"h. "qua.led "ca c" became.5 A$-"d08" ) AI'PL.£SOFT does 00 t elimin .. t .. "06e", but j.uat opens neW file for '·'dog". As a result, a lot of old <ltIlrocters &lowly fill clown from HIMEH.: to the top of the. ar r ay space. AI'I'LESOI'T ",H1 automatically "house-clean" when thi. old data Tuns into the rrcc Drray space, but if you are USing any of the free .pac~ for machine lnllguage progralllS or high-reaolution page buffers, they may be clobbered. Uotng a statement of the form X .. F'RIl(~) I' 'riodically within your program will force the house-dea.ning to occur and pr vent such events. Although expr is BO it should not just used to hold tbe be aomething illegal. pa ren theaea apart, it is eva lue red,

parsed

as a reserved

non-space

character

is

a

parenthesis.

1m,.. deC UlVER~ll 1_ & clef IlURNAL i_ & de F

rusn

HOME
No parameters. Moves curaor to upper left s~reen position wlthin the scrolling window and clesrs all text within the .. indow. This command is identical to "CALL -936" and to "esc @ return".
FLASH

NORMAL

INVERSE

CLt.\R
CLEAR

I;""

d .{

Thse three commands are used to set video output modes. They do not use pu(ameters, and they do not affect the display of characters as you type tl1('" Into t:he computer nor eharae ceca already on the screen .. FLASII sets the video mode to "flashing", ao the output ftom the computer Ia !lltern.ately shown on the screen in white on black and then reversed to blade on whlee. lNVBlISE letters ae es the video mode so tha.c on a white background. the mode to the usual the computer's output prints as black

Ilo parameters. and stocks.

Zeroes all variables,

arrays and strings.

Re9~tS

pointers

NORl'lAL sets

white.

letters

DO II

black

background

, for

52

~

input and output.

53

SI'frn

t"""

"1'
I..
d;;)[

.Il

in

only

["d1ting

only)

SPEED - aexpr

sees speed at which characters ar e to be sent to the s e r een or other ioput/output do"lce5. The slowest speed is jI; the fastest speed is 255. Out of range veJ.ues will cause the message ?lLLEGAL QU~~1TY ERROR to be displayed.

Til t peat key 1s the key labeled "REPT". If you hold down the repeat key wll.1.1 pressing" character key, the character will be repeated. Th" first lim you press the repeat key alone, it "repe.ats" che character last typed.

,,1 ht
~ !

.'TiIW

f_

rro~

anly m only

(edt ting

(edit lng only) only)

esc II e!lC II esc C asc D

i_

o"ly

tllm only i..., only 1m.. (lilly

(editing od:>,) (ed t c l ng only) (editing on lv ) {ed t tinll only)

TI> right-nrrow key moves the curSor to the right. As the cursor moves, ea~ Character it CrOsses on the screen is copied iota APPLE U's memory, just asifYou~yped thE! character. It is 'uN d. w:1eh the repeat key, to ssve re typing an en t i Ie 1ine when on_ly mino r changes a Ie required.

The escape key, labeled "ESC", may be used in conjunction with the letta" keys A or B Ot C or 0 to move the cursor: to mOve tbe curSor ooe space, ~ press the escape key, ~ release the escape key and press the appropr1Bte letter key.
moves

The 1 ft-arrow key moves the eucso r to the eft. Each tim.e the cursor moves " the left • .!!!!!. character Ls erased from the program line which ~ ~ cur"ently.sv.P!!!.&., regardless of ... at the cursor is b moving over. The screen is ignored by this command, and nothing is changed tan the 9c:reen ~

~

c ucaor

one

esc B eac C

esc A

esc D

space to the right left: down up

these escape commands do not affect the cbaract,ers moved over by the CU~60t: the characters r~in botb on the TV screen and in memory. By themaelvea, the escape comlllllDds also do Dot affect the program line being typed. To change a program line, LIST the line on the screen and use the escape COmmands to move the cursor so tbat it sita directly on the very ~ character of the LlSJed 11ne. Then use the right-arro,,", and REP! keys to recopy the characters from the screen , typing II differentcharacte,r whenever the cursor is on a character you wish to change . If you did n.ot LIST the line, do not cap)' the prompt character (J) that appears at the beginnLng of the line. Finally, press the RETURN key to store the line or execute it.

Unless you are currently typing a line for which return has not yet been pressed, he left-arrow key has nO current program-line characters to erase. 1" this case, its use will cause the prompt character (ll to appear in column II of the next lower 11ne, followed by the cursor. That Ls why the turBor frequently cannot be moved to column 0 of the TV screen by using the Iof [-arrow key: 11 current p.rogram-line character must be erased for each move. For pure mo"es, without eJ:,"sing or copying, see the escape commands.

trl X

L_ onlY

T lIs the APPLE I I to 1800 r e the 1:( ne cur een t1y being typed, ... 1 thou t delct.ioa any previous line of the same line number. A backalash (\) is displayed a~ ~he .. d of the line to be ignored, and the cursor jumps to " ~olumn ~ of ~he following line. This command can 3 so be used during a r sponse to an INPUT instruction.

54

55

56

OW v,ar

slIbscrlp

t ,[ .var {

subscr

tpc ) I

dd

When a DIM aea cement is execu ted, it se ts as1de space fo. the au-ay wi th the n3IQe v,ar. Two byt:E:s Ln wemory az e us-ed for st.orlog an ::::l'rr,Q), vat'1able name, t;wo for the .siz'e' of ehe array, one .for the numbe.t of d1me,nsion.s, and two fo'f each di .. ension. As discussed below,the smouDrof space allocated for. th .. elements ,of an array depends upon I:.he type of ".-rray. Subscripts nm&e hom II to \subscript \. the number of e1eme.n ts n.-<l1,.en5iol1,,1 array is (\subscript 1\+1 1*(\slIbscdpt2\+1 1".·." (\subscrip.tr.\+l). E. g. DUI SHOW (4,,5,3) 9" cs asi<le 5*0"4 e Lemen es (l211"lements) elements are; SHOW (4,4, I) SHOW (~,~,2) and so on.. 'The can DIM ?OUI but me.lC,i .. um number of <l1m ...n510n& for an array 1s 88, even contain only 011e element' A(~,IJ'., ... ill ..here char e are a9 ~et05 g1ves an OF HEMORY ERROR DIH A ('iii" II" ••• iii) ",here the"" ,at:!! as z·erOB does noe. lleach in an

I.RN (g""pr)
function l( the RrNIrat than
1S'rK lUG 700

rills, 2~5.,

re.tur na the nu ..ber of cnar accecs 111 a string, argument 1& 11 concat enat Lon o.f strillge whose 255, the message
LONG gRROR

between comhLned

0 and length

is

1<1 glvtn.

'.

Typi,cal

MilS (nc>I.pr)
I'

dimension

1'111 [unctIon K converts \a""pr\ into a 3,ring which represents that value .. xpr is eVlIlu8,tec! before it is convened to a string. 8111.$ (lG{! ~01l IIGIl ~IJ~) returns 1£+ It. t r \/.Iexp"'\ el<ceedS the limi es for r eaLs , then the meaaage 10 VEIl FI.OII Ell ROR 'ttl d I "I,l_oyed.

In pracUce, ho""""I."" the size of ar rays is chen limited much more by thll. amOutH of ",emory available. Ea ch inteser array l!lement occupies 2 byte,s (I'~ bin) in m..mary. E"ch real ar ray eler.lent occupies 5 bytes (1,11 'bUs) in m.... ory. Stdng array variables use 3 bytes far each .. le ... me {one fo·r length, r .. o for a location pointer). stored as an integer array .. hen the array is OHlenstoned. As the strings tlleoocl vee, ,a're. st ored by ehe program, they occupy a.n addt t ronat one byte per charac cer . See page 1]1 for :,""p.

I. I.'

1:h10 functio"

a:ttel!lpts
0f

to

r ...tllr n.ing the va Iue

in terpret a string tlla I; nueber .

as

a teal

or

Oil integcr.

If an ,Q rray DIMensioned. in ched'emen

e Lemelle t'
G

is used

in

Al'PLESOFT

6.691&n£l

..

a p rog ra.m beto re that 'Variable maximum sub,scr1pr of ill for

16 eseh

dim.ansioll

9ubsc.rip't.

USing £I variable "hose allbscrip~ is larger than the .. a"imum clesignac,ed., 0-, \.Ihid\ calls rOt .. d if fer en t number of <I 1.."n91009 zhan spec if1ed in a 0111 stat<!llll!lIt, causcs the ? BAD sussca 1 PT EiRROR mes"uge to appear , If t.'he program Dltlenslons DIMensioned arra), (even ?R.ED I.H 'D ARRAY ERRaII. appeara . The an arra~ that has tile same nam" a9 a prevlo"sly by d .. fault usage), chen the me88~8Q

'[II' [lr8,[ character of the string muSt be aposslble item in '" number (l!!mHnll spac"s are a.cc,"ptsble), or Il 1s retutned. gach character lh"re.a r"er i8 likewise axa .. ined ,.until the Hut definitely non-numeric hllrocter is encountered (intervening spacas , decimal pOiIHS, + and - .signs. nll<l J:: 8",,' 811 possible nu .. eric chaeaceees int:.he correct. context). Tho I trat non-nueer Ie character and a Ll, subsequentcharacterB lire ignored, and cno 81:'<1ng co that point is evaluated as a. real Dr an integer.

",'sum,," e

H

a string
0

if DIMensioned

?SmINe: 'tOO Ip g:l_ven.

concaten,,~1on consisting f VAL, th e message
LONG ERROl<

of

",Qrethan

2:55 chllrll'>ter9

is

the

1n<li,,1du41 strings in a string array a r e noe dimc.".ioned ,. hut as necessary. The Stat6m.ent. WARO$(5) .. "ABeDE" creates a, str1t1,~ ,of length 5. The statement WARD $ (S) • "" de'-allocates the space allotted to the string wAlUJ$ (5). A string con t8in a maltimu", of' 255 chacac cOlI'S"

grow and

shrink

l£ the abao lu re rlUIDbctcolltains ?OV.IllIFLOW ERROR 18, prosented.

va.Iue of tile nueber 1I!0re than JB digits

return,,-d (including

is

IIrna tel: tra.iling

than I El8. 0, 'if the ntoes). the message

may

Array elements

are set

to

zero

.. hen RlIN Dr CLEAR Ore executed.

58

59

OIlR

s

1='

dd

I

rcnr

deC (sexpr , aexpr )
unction re,turns the last (r1gbtlUost.) \acllpr\ c.baracters of \scxpr\:

CI!R$ (aexpr ) A £,mction that re cuma the ASCII charac t er which corresponds to the vulue of sexpr. \ae~pr\ must be between 0 and 255, inclusive, or the message ?ILLEGAL QUANTITY ERROR appears. Reals are cODverted to integeIs.

RlGHTS
TIILII

I'll '(NT IUGHI$("APPLESOFT'· IlOf'"I'WAllE

+ '"WAR!;". 8) >- LEN (sexpr)

ASe ASC

lllll:! (, def (sexpr I

HI') P"tt of tnis command may be omitted. If \sexpr\ )!leUT$ re eurns the entire string_ The message ?l LLEOAL.QUANTITY ERROR h dUplayed if \aexpt\d or \""lI]>~\>255. ItlGHT$ (aexpr , aexpr ) ~ MUlHsIl.X!>", LEN(s"xpr)+l-\aexpr\)

chen

This function returns an ASCIl code (not necessarily the lowest number) Ear tbe first character ",f \sexp.\. ASCII codes in the range 96 through 255 ",tll generate characters on the APPLE which repeat those in the range ~ through 95. However, although CHR$(65) returns an A and CHR$(193) also returns an A, APPL.ESOFT does not recogn!:>:e the two as the Bame Ch8rllcter when using string logical operators. If a string 15 the argu .. ent , it must be enclosed :In quotation marks, quotation marks may not be included within the string. If the string null, the '...... sage ?lL.LEGAL QUANTITY ERROR is give,n. and 1s

If the "$" is omitted from tile command name, "rtthmot1c variable na .. e and the m.esssge 7TYPE HISMATCH ERROR 18 dl!1played.

APPLESOFT treats

RIGHT as

an

H~OS (sexpr,

aexprI

I, aexpr2])
the character

®

H'ID~ ce l.Led .. Lth two argument .• retur'ne the substring starting at \0 xprl\th character of \sex"!,r\, and proceeding through the last (!If \Bellpr\. the ASC function on errl

An atte .. pt to use 1SYNTAX ERROR mes"age..

@ results

in

the

I'RINT HID$("APPLESOFT",
I'Lf:SOI'I HLD$(sc,xpr, aexpr)

3)

- ItIGHTS(sexpr,

LEN(sexpr)+1-\aexpr\) \aexpr2\ characcers of \sexpr\, and proceeding co the right.

LEFTS

Imrn ~ d f aexpr) re.euens the first (leftmost) \aexpr\ chneaccer s of \se~pr\:

HlD~ called With three argu.ments returns bllg1nning 111.<h the \aexprl \th character

LEFTS (sexpr, Th'!s function

l'RJNT HID $("J,PPLESOFT",
Pl.ESO

J, 5)

PRINI LEFT$("A,i'PLESOFT",5) APPLE No pan of this command can be omitted. the message 1lLLECAL. QUANTITY ERROR 1s displayed. If \aexpr\ is a CellI, it If \8I!xpr\ CBturned. If \sellpr\<1 or \aexpr\>255 then

If \aexprl\>LEN (sexpr), \lIexprl \+\aexpr2\ exceeds Qf any string), Bny extra ebaenct.ee if LEN(A$)-2SS,

then HID$ returns >1 null string. 1£ the length of \aaxpr\ (or 255, che maximum length is ignored. ~I1D$(A$.2S5.255) returns on" Ot.hervise the null strin8 is returned. ar e OutBide the range I. through 255,

is

converted which

to

an

integer. the Btring srB

> LEN(sexpr}, only Any extra positions

the characters are igoated.

CO(lstj tute

If either \sexprl \ Or \aexpr2\ lnclusive, then the message ?lI.L.EC",L. QUANtlTY ERROR Ie d1Bplayed.
he $ is omitted from the nrl.ttllo.8tic variable na .. " and lTYPE MISMATCH ERROR 18 displayed.

from the command name, arichmetic variable name and the message ?TYPE MlSMJlTCH KRROR 1s displayed.

if "~" om1tted 15

APPLESOFT treatS

LEFT as an

command name, Ch.. "e9ssge

APPLESOFT treats

H[D as

an

60

61

STOIU;
R ',CALl.

STORE avar
RECALL Byar Thesl! A.[ray u.sing commands names are a different s tcr e and recall arrays from cassette

."pe.
back

both fill array 8 vil:.h mixed-up DIM B(5,5.1~) RRCALL B works fine, with zeros in array

numbers

from

array

A; while

!I's

extra

elements.

not "to~ed w1.th their values, So an array may be read name than [hat used "'"itkthe STOllE eomlNlod.

The dimensions of the array named by the RECALL statement should be ideotical to the dimensions of the original array as it was STOREd. Par ex.a.mple, if an anay dimensioned by DIM A(5.5,5) is STOREd, then on" might RECALL it into ao array dimensioned by DIM B(5,5,5). Failure to observe tbi. "Lll result in sc racb.Led numbers in the RECALLed array, extra eeros in the array, or the ?OUT OF MEMORY ERROR. In general, you ",ill be given the ?OUT OF MEMORY ERROR mesa age only when the to tal number of "lom"o ts reserved for the ,n ~ay being RECAI.Led insuift"iellt to contain all of the elements of the atray thllt ",as STOREd. DIH A('>,5,5) STORE A saved 6~6~1'> ele1l1ents Oil the cassene tape. DIM 11(5,35) RECALL B ",111 ... aul t in the m.essag"

\I have discussed two "rules" for SI'OREtn,g andRECAL.Ling " r rays with eq'ual """bers ,,{ dimensions: I, Only the Laat dimension of the array RECALLed """)I be la>:ger than the last dim.cnsion of the array STOREd. 2. The total number of el ..ments RECALLed must at lea9t equal th numbe~ of clements STOREd. If rule 2. is followed, and if rule 1. is followed for the dimeosions which Dre common to both arrays (these muSt be the first dimensions), then one may IIECALL an array with more dimensions than the array that was STOREd. An F.RR message is displayed, but program "",,,cution continues. Ill!! 8('1,5,5,5)

is

RECALl. B

will work fine in theabov" exa.mple 'xtrs zeros 1n array B), but

(after

the

ERR

message,

and

with

many

IHI! MS, 5, 3, 5)

and scrambled numbers Ho...,ever, DIM B(5,25) RECALL B 101111 cause the

ERR

in array

8, but

program

execution

will

continue.

RECALL B ..UI .f111 array !I with scrambled nUOtbe1:8 (aft"r the ERR roessage) , and nus 8(5, S, 1,1) HECALL B "Ill cause th .. lOllT OF MEMORY ERROR h"cause the 6*6*2*2 elements in array B are fewer than the 6*6*6 elements STOREd in array A.

Only real cease.
to In contain this case, array l:I all the elements of Although "ubscr1pt

and to an integer

integer arrays may be stoted. {lrroy USing the ASC function their

String in order variables

arrays muSt be converted to be scored, ",tthout mention of The

to be displayed, and program execution ",i11 c.ontsined 6.26 elements too few elements srray A,

?OUT OF MEMORY ERROR

I,rograro

STOR"E and RECALL reEer to Or dimension, only arrays

may be STOREd or RECALLed.

If ,the arrllY RECALLed has the. Bame number of dim.ensions [ DIM A(S, 5, 5) speciUes an array of ~ dImensIons, each of size 6J as the array which was STOREd. any o.f the dimensions of ~h" RECALLed array may be la~8er than the corresponding dimension of the STOREd array, lIowever, scrambled numbers in the RECALLed array will result unless it 1s the ~ dimension of the RECALLed array which is larger than the last dimension of th .. STOREd array. In every case YOll "ill find extra zeros stored in the excess elements of eh" RECALLed array, but only in this last cas" will you find the zeros wlle.re you would expect them. After storing an array with DIM A{S,S,5) STORE A you will find cbat DUI8(10,5,5) RE~ALL B and also DIM B(5,1I1, 5) RECALl.. B

11111 "(3) • 45

1111"·;27 12G STORE A
stores on tape the array nrrn~ is dimensioned to 21 1.0 the program). elements A{~J through A{Llll (by default, the eleven elements), .!!2..!:. the variable" (",hicn equals

is no prompting message or any other siBnal issued by the STORE lJlJltrue.tion; the user must have the re.corder running in r cord mode when the :lIlscruccion is executed. A "beep" s18na~9 the beginning of the recording, nnd nneube r "baap" signals the. end. The program lliU DIM 8(5,13) Jill B - 4

n'cre

nil RECALL 8

r<'od~ from tape the 84 (6*14) array elements B(~,II) "" Lun o( tha variable B is no t changed. II.lInln, there is no prompting o.es.age; "beeps" signal lind of he recording,

through the

:8(5,13).
and

The the

beginn.ing

62

63

U e tther 51:DRE or RECALL cc",ta1ns an. array n,,,,,e net p,.,vi,ously DIMensioned or used with a subec r tp t" the messes,,, 10m OF DAtA ERROR is g1 "en. 10 t",,,,,,d'iat,,- .. ,,ecu'tion mode , if either StORE OJ" RECALL refers to an array nam.. that 1$ defined' in '" deferred-execution program line, then 'the dde.ued..xecuct.on program line ,"".s,t nave been e"ecuted pri,or to tbe STOI,tE

or

RBC,ALL.

STORE

and

RECALL "an

be interrupted

only by

n!Set. ChsJ"Bctels of

1£ the re.se rved word s STORE or RECALL S re used II" 'the first ally ',"ar1shle aame , the commands !My be eKCCU ted befor ... sny ?S'i1fUX ERROR mesaage is. g,iven. The ,6 ta temellt

STOREI-lOllSI':<'S will c"usethe ?OIJIOI' DATAERROR ..esssge. un.less an ar ray has been defined .. hose name begins ehara.crera RD. In the later case" Af'PLESOFT ill attempteD ..
ar ray ; first
you'

11 hear

one

beep.

then

a second;

f !.n.ally

wi th -the STORE 'the the ",essage

?SYN'I'AX ERROR wUl be. :pr!.llted as APPLESOFT tries to parse the rest of tha ar a tment , ""S". To c ...t ahort the beeps and error messase you can press the RESET key. The lit a ceme nt RECALLOUS-2J4 will cause tile message to be displayed, unless so array has been defl.rH!d whose name begin ... wi til the charac t er s OU,. In the le. ee er C:S'S" , APPLeSOfT "1111 wa.it indefinitely ~or a" ac(ay to auiv" from the CIIssetce eueoruer , The 0111y wa)' to rega!.n control of the computer 1. to p<e88 the RESET key.

?OUT OF DATA ERROR

64

INPUT

[.tring

;} va~

l{, var}]

If the optional scring is left out. INPUT prints a question mark and walLO for lOhe uSer to type a number (if var is an arithmetic variable) or ch..aclOers (if var is a string r vadable). Ihe value of this numbar Dr
striog 15 put into var. Wheo the string is present, it is printed e .•actly as specified; no quest!!)" mark ,. spaces, or other puncnua t i.on al:e printed after the atring. Note ehne 001), one optional striog may be used. It must appear directly aiter "UfPU'f" and be fOllowed by a semi-colon. INPUT will accept only a real or an integer as numeri.c input, not an arithmetic expression. The ehaeae ceca space, +. -. B, and the period a"):C legitimate parts of numeric input. INPUT .,ill accept any of these characters or any concatenation of these characters in acceptable form (e.g. +£- is ac cep cab Le , +- is not); Such input by itseLf evalua.tes 86 II. In numeric input, spaces in any pOSition are ignored. If numeric whicb is not 8 teallo on i.nteget' , a comma;or: a colon .• tbe messa.ge. ?RBENTER 19 diBplayed nnd the INPUT instruction re-eKec:uted. input

succesarve variables get successively typed values. String v,,"riables and "r1 hme t.Lc variables may be mixed in the same INPUT statement but the user's r eaponaaa must each be of the appropriate t),pe. Thet;ped responses may be separated by comnas or returns. As a result. if a user types commas tn a response that does not begin With 8 quotation mark, the commas are interpreted as response separators. This 1s true even when ollly one reoponse is ·axpec.ted. lC II colon is typed in an INPUT response that does not begin with a quotation mark. all characters typed subsequentl)' are ignored. After II ~"lon. commas are alao ignored. so the at ar t of another response muat be signaled b)' II re turn.

1C .. reICurn is encountered belore all the "ar's have been assigned responses, ~wo question marks are printed to indicBte that Sn additional r('lfpanse is expected. When" return is encountered, if the response cantnins more response fields than the statement expected, or if II colon cds 8 in the fina.l expected response (but not IoIithin a striog), then the message ? EXTRA IGNORED
ts prJ,nted I [ a colon and program execution continues. of an INPUT responae., string. be followed the

r &ponse 1s evaluated
Hote

Or a cammo 15 the firs t character as Zero or a9 the null

If ONERRGOTO is uaad , with another GOTOin the error handling :routine to returD the progrs·m co the offending INPUT statement, the 86th INrUT error may c8use the program ta jump ta the Monitor. To recover, use reset ctrl C return. This problem can be avoided by using RESUMEto return to the INPUT statement·. Similarly. a response assigned to II string variable must be a s10g1e string or literal. not a "tring expression. Splices preceding the first: characner lI.re ignored. li the respoose is a SUing. then" quotation O)lIrk anYlinere within the string will cause a

that Ln the INPUt command the optional at r mg must Iwml -colon but variables must be aepa rn t ed by C:Olmllll".

by a

C tl C Can Lnterrupt an INp·UT statement, but o(1)' if i~ is charaeter typed. The program halts when .return i. typed. CONTinue execution alter such a halt results in the

theftrat AI' attempt

to

?S\'NTAX ERROR
ho.rnc eer

mNIGoge.

e cr L C is eyped. the

treated

as any other

character

if it

is not

the

first

?REENrER

message. Bo.,e""r. Within II string, all characters except the quotation mark, ctrl X and ctrl M are accepted 0.8 characters for the string. this includes the cololl and the comma. Spaces follOWing the final quotation mark are ignored. If the response is " literal, then quotation marks a r e accepted 8S characters in any part of the literal except th~ first non-space charactex. Spaces fallQwing the last character are accepted as part of the literal. However, the COmma and the colon (and ctrl X and ctrl Ml sre not accepted eh.. racters in the 11.teraL the uset simply presses the REtURN key when .. Du",eric respOnSe is expected, the message ?REENTER is printed and the l~PUT instruction is re-executed. If the RETURN key alone is typed when a string response is expected. the response is interpreted a8 the null string and program execution continues.

Trying

m.".ongo.

1lLL GAL D!RECT ERROR

to use

INPUT com_nd

10 direct

eKecution

mode causes

che

d 88

"nly

GET v r
F tchc6
9

If

a Single chsracte~ from the keyboard without diaplaying r""" and w'ithout requiring that the RETlIRNkey be pressed.
of GET S"8r has a fe~ surprises:
@

it on the

The b~avior

c rr l

returns

the

null

character.

the resui e 0.£ GETting II left-·attow or c r r.l II may also PlINT as if the null character were being returned. ctrl not C i8 treated as any other character; interrupt program execution. it does

66

67

While

Al'I'LESOFT

WIIS

not

designed

or

intended

to

GBT values

forarichmetie

var Iab Ias , you may use GEt allar
subject to the following

he fJrst cha ruc t ar of an element. With this exception, r' READ into string variables fallow the same rules as " si,gned to string variables:
t

DATA e.Lemen t s which for INPUT responses

stringent

limitations:

F,1ther strings Spaces
the ignored. Any quotation and th ..

or

literals

may be used, and

or

both.

GETt! ng II colon Dr a comma resu1 rs ill the, 7EXIa... IGNORED message, followed by the recurn of a zero as typed value. The plus s f.gn , minus aign. ctr1 period all return a zero as the Typ1ng a return ox non-numeric @. E, space typed value.

before the
mark

first cbaracter
that appears

following

a "tring are
causes the

always

within

a string

1 SYNTAX

ERROl! message, but all other characters are accepted char ac t e re 10 that strin,g, including the colon and tbe comma (but not including ctrl X Bnd ctrl M).

liS

input causes

the

7SYNTAX message

ERROR
to

lf an e1emeot

be displayed.

is a~, then the quotation mark is accepted as a valid character anywhere in the 11teral except as the first non-space character; tbe colon, the comma, ct r I X, and e t r I Mare.!lQ..t ac c ap t ed , for more details.

With ONER!!. COTO•.• RESUME, ["WO consecutive GET errors will cause the system to hang until RESET is pressed. If GOTO is substituted for RESIlMI, all is well until the 43td GET erlor (in any order), whe,,,the program jumps to tbe l.fooitor. To recover, use reset crrl C .etuln.

s~· INPUT

Because
numbers

of

these

limitations,
resulting string

it

1s recollUllended
to a number

th .. [ serious

programmers

GET

I)ATA elements may be any mix.ture of real e , integers, strings If the READ statement attempts to assign a DATA element that ~ literal to an arithmetic veriable, the 7SYfiTAX ERROR m aBage 1. given for the appropriate OAIA line.

and literals.
is a string

or

using using tb .. VAL function.

CE'T svar
and

cenvae u the

If the .list of elements in a DATA state.ment conrains a "non-existent" element, theo a zero (numeric) or the null string 1s returned for that "L ment depending on the variable to .. hich the element is assigned. A "non-el(istent" element occurs i .. a DATA stetement When any of the following 161 t.rue: There is no non-space char; .. ~to>r between DATA and return. Camilli! i& the first non+apac.e ch,ua.cter following DATA. l) There is no pon-spsce character between two commas. ~) Com"", 1s the lost non-space characte, before return. statement up to is three READ elements consisting of zeros or null str1ngs. I)

llATA

del

'.nly [C, (literallstringlreallinteger])]

DATA [literallstringlreall1ntegerj

Z)

This statement creates a 11st of elements which can be used by REhD st.at.emllnts. In order of inatu .. t f on line e number, each DATA statement adds its ell!ments to the list of elements built. up by the programs's previous (lower 11ne number) DATA s~atements. The DAtA statement does not have to precede the RFJJl statement DAIA statements can appear anywhere throughout the progrltm. in a progra.m,

So when this HIli O.... " U It can return
WI1Cll used tn but I ts data

DATA elements which arc READ 10to arithmetic variables senetaJ.1y follow the sa .. " rules as for INPUT responaca ass:lgned to arithmetic:. variables, However, the colon cannot be Included as II character in a num.eric DATA
e.lement.

11l1med1ate e"ecution mode, elements are not available

DATA does not cause to a R.EAD statement,

a SYNTAX.ERROR,

In:AD

1mm

6

def

If

crrl

C is

a DATA element,

it

does

not

stop

the

program,

even

when

it

is

READ var «,var})
When the H cst READ statement is execue.ed in a progca.m, its Urst variable [ok". on the value of the fiut element in the D"'T'" list (the DATA liat consists of all the "lements fro .. all the DATA statements 1n the stored program). The second vR.liable (if there is one) takes On the value of the s cond element in the DAT list, ... and 80 on. When the READ statement finishes cl(ccution, it leaves a data list pointer after the last element

69
68

of data used. The next READ statement executed (~f data lht from the position of the po tn te.r , Elthe~ potnter to the first e1e'ment in the DATil list.

any) beg Ins USing the RUN or REStORE sera eh the I'ItINT tab f1eld ] does not function properly i.E the text Wiodo,", is SeC to l"s. than ]3 pos1·t1ons wide; the fl~st character may be printed outside dIe text window. HTAB "all also ""uSe I'ItINT to display a first character outsLd" the text window. 1£ all item On the list is followed eon,,-"tenated: it is printed directly by a semi-colon, afterward "'ith the" the n"-'<C item is ne intervening spaces. an! concatenated if is bes t lllus t ra ted

An attempt to READ more data than the data list contains produces the message: 10UT OF DAUERROIl IN l1oellu.m where linenum ts the line number of the READ statement which asked for additional DAIA. In immediate mode. you can only 1t!:AD elemenu from DATA statements which e xi.s t a8 line8 1.0 a curren tly stored program. The "1",,,.ent .. of !lATA in {! stored program can be R£AD eve" 11 the Btored program haa not b....n RUN. H no DATIl statement has been stored. the message 10UT OF DATIl ERROR is displayed. Ex.ecueing a p eog r am in immediate mode does.!!!!.! set the dn en list pointe.r to t.he first element in the DATA list. Extra data left unread 1s OK.

ItelilB listed ",ithouc lntervening commas or semi-colons hl> 1 te.m.s can be parsed Withou t syn tax problems. This by e>lsmples: A.. I : 11-2 : C~3 : C(4)"S PRINT L (A)2 (B)3C (4)C5 1I22357 PRINT A."II."C.4 lilB.3.4

PlIlNT
PRINT • del RESTORE has I1s~ pointer data. 1.1st.
00

l/J{2*4)51 • ]])333])]851 3.4. S. 6.

3.4.5.6(1

pars.Uleters or options. This Statement (see the READ and DATAstatements) back

merely moves the do II to the beginning 0 th ..

PRINT "orks very hard to figure out period as a decimal point, it treatS the above exs~le9.

what you want. If it can't interpret it as the number 0, as illustrated

a in

Pll

rr

PRrNT followed by a list of semi-colons does nothing more than PRINT alone, but it is legal. PRINT followed by a 110t of commas spaces one tab field per comma, up to 9 limit of 239 characters per instruction. •df [{.I; [(expr))})

PRtNT [(expd PUNT {;}

I [.I; I

PRINT {.}
The quear f.oa mark as PRINT. ( ? ) may be used as an sbbrevlation for PRINT; it LISTs

PRtNT A~+BS gives a 1S1:RlNG TOO LONG ERROR if the length of th~ concatenated strings 15 greater can print the appsrent concatenation using PRINT A$8$ withouc vorrying about its length.

than

255.

However,

you

Without any options, PRINT caus .." line feed and r .. tur" to be exeeuted screen. When options are exercised, the values of the Ust of the p expressions are printed. If neilher II comma nor a semi-colon end a the a lin.e faed a nd return are executed following the last item printed. item on the list is followed by a comma, then the fiut character of next item to be printed will appear in the first pos1t~on of the n K available tab field.

011

tho
1" i 6 .. f

e1f'I d 11"".
T( 1111

lte

IN' aexpr
Sleets input from slot \sexpr\. providing input for subsequent slots I through 7, as indicated Usad to specify INPUT Statements. by \sexpr\. which peripheral will Peripherals may be io be

The first tab field ~ompri8e8 t.ne leftmost 1.6 printing positions in the text windo,",. positions I th~ough 15. The second tab field cc cup t.ea the nex[ 1.6 p0s1t~on8 (17 through 32), and is available for tab-field p~inting on l)' j r nothing is printed in pOSition 16. The third tab field conaists of th remaining 8 print1ng pOSitions (33 through 40), and is avsilable onl), if nothing is pd,nt ..d in pOSitions 24 through 32. The siz" of the sc re Ll.mg window for commands (see Appendix J). text may be changed using various
1'01(1)

indicates hat subsequent input "'ill h peripheral. Slot ~ is nOt addressable peripheral device.

IN' II

be from the keyboard instead from APPLESOFT for use with

of a

70

71

If no peripheral is reae·t ctrl C return. If \se.xpr\

in

slot

\aexpr\,

the

system

will

hang.

To recover,

U9'

is less than \l or greater ?ILLEGAl. QUANTITY ERROR is displayed.

than

255,

the

message

The message ?TYPE MISMATCHERROR Is displayed U you try to gi"ve 8) a string variable name to an arithmetic expression, b) a string variable name to a literal, or c) an arithmetic va ria.ble name to a s rringeKpress ion. If you try to give aD arithlll.etic a e reept s to parse the literal as

or

" .. r Lab Le name to a literal. an ar'ithmetic expression.

APPLESOPT

If \aexpr\ unpredi~table
For

is in

the ways.

range

8 through
See

255, APPLESOFT is altered FR'.

in

slmilar

transfer

of

output,

IlFF del f'N imm Ii def DEF FN name (real FN name (aexpc2) avar) ~ aexprl

PR# aexpr

PR"
to PR'

7,

traoafers output inclusive. output

to

slot

\aexpr\,

where

\aexpr\

muat be tn the zange I

iii returns

to

the the

TV screen, specified return.

not slot,

to the

slot

0.
will hang. To

user to deE!.oe functions 1n a program. First the function FN Ilame is defined using DEE. Once the program lioe DEFining the fUDction has been execu ted. the f unc tion may be used in the fo em FN name (argumen t) where the 8 rgument aeKpr 2 may be any srit hOleti.:: expression. The DEFi!!i t.1on· S aexpr l may be only ODe program line in .length; the defined f'N name may be used wherever arithmetic functions may be used in .... PPLESOFT.

AllOYS

If

no peripheral is in recover, use reBet ctrl

system

C

1£ \aexpr \ is less than Il or great.er ?ILl.EGAL QUAN1ITY ERROR
is disp layed.

tha.n

255" the message

Such functions may be reDEFined during the course of a program. The rules for "sing arithmet.ic variables still apply. In particular, the first two characters of name muSt be unique. When theRe line9 IG DEF FN ABC(I)-COS(I) 2!1 DHF FN ABl'(I )-rAN (1 l 8r" executed, A2PLESOFT recognizes the definition of an FN AB function in line lli; Ln Une 211, the FN AB function 1s redefined. In the DEF instruction, real avar is a dummy variable. When the user-defined function FN name 1s used later. it is called with an argument llexpr2. Thia argu",,,nt is ,substituted for real avar wherever it appears in the definition's llexprL. aeKprl mIIY contllin any number ofvarlsbles, but of cnurae only one of those (at m09t) corresponds to the dummy variable real aver, Bnd therefore corresponds eo the argument variable. The DEFiniHon's Teal avar neea no appear in aexp r l , In rha e c aae , when the function is used latar 1n the progralli. the function's argument is ignored 1n evaluating aexpe L, Even in this case. however. the function's argument is evaluated itself, so it must be something legal.
For

If \aexpr\ unpredictable For

is

1n the ways.

range

8 through

255,

APl'LESOFT is aleered

in

s1mJ.ln

transfer

of

input,

see

IN~.

(LET] avar l aubac.r Ip c] ~ aexp r [LET) svsdsubscdpt) - sexpr The variable expression LET A-2 and name on the on the right. left is assigned the The LET is optional: va Lu.. of tile at.dog or

I!I" I iii

"'-2 are

illstanc:e.! DEF FN A(II) - 2 '" W + PUNT F~I A (23) 12!1 DEF FN BeX) - , + 3 l3{l C • FN Ben) FN B(Z)

w

equ I valen t ,

1~1IPRWT G 1511 DEF FN A(y) 1611 PRINT FIN "'(G)
RUN

+

Y

69
7

72

14

HI A (23)·2*23+2.) FH Be8nyth1ng)-7 new FN A(7)-7+7

I
) )

73

l..f " def.nred-ex""u

tion ERROR

DEF I'N nam" statement

is

<'10 "",,,,,,'[ed P" 10r t

to

".1nl\

FN nalll... the .
1mIDEF'D FUNCTION

messas" is displayed. User-defined string funct,ions ar e not allowed. 'Functions intege-" name%. for name or for teal avar are not allowed. When" neW funceion is d.efined by a DBF statement, used to s tore 'the pointer to the definition.
I)

defined ,milll!.
in m.em.o1::Yeo a

1111

bytes

ow••• COS1II

74

OOIU

to...-'

def

Branche.s line" or

tocne liue whose Un" nllmbe,[ 19 11.ne.n\).1II. If H linenum 1s absent from the GOTO state:me"t, numhe r
Q

cbere 1s 00 ""ueh then the message p"""Sram J_t,ne

?UNDEF'tJ S"EATEl'IHIITERROR ill linen 11m is displayed, where linenum i9 the 1 ine containin,g [he GOTO sca cement.

f the

If' string TIIEN••• .. hen e""cuted more than tVO message ?FCIlliULA TOO cmW[,EX ERROR to be printed.

~

or

rhr ee

times

in

II

gtve"

program,

causes

the

if

hun'

c1.. t instruction}')

IF ""1'1' THEIl inst1'uctiO[J [{: IF e"pr lH£N tcoroi linenum 11' e"PI' (tIlEi'll GOTO linenu ..

II e,"PI" is an arithme tic e:~p[esslon whose v",lue is absolute value is greeter than about 2. 9381lE-39), be true, and any insi:ruc [i,on(.) followi'lg .HEN are

00 t zero (and Whose \e"pr\ is conside);ed executed"

If e><pr isa serin,g variable and ~h" previous state .. ent aas Lgnad the .tring 'CO.!!.E:Z s~ring variable, then \""'pt'\ evaluates 11.'0 zero. For lnst:anc,e, the pr'og ram 12(1 11' AS THEN PRrNT "AS" 1311 IT B$ THEN PRINT "B$" 1411 IF X$ TIlER PUNT ")($" when IIUII. pr Incs A$
'[0

~

null

as
XS

If exp r i s an arithmetic expreSSion whose val"e is 'e":'O (or whose ab501tite value is Le s s thao IIbout 2., 93813E-39'). anl' 1nst[uct10ns following THEN are ignored, and execution passes on to the iOBt ['UC tion in the nexe numbcced line of the p cogr'amWIlen the IF 5tatement ze.rc , AFPLESOFT .. 111 occurs 19no~" in the an immediate exccut.d on prcg,r4m., if \""pr\ en t1 r" rel'llainder of the progrll.OI. is

because line

sn'ings

A$,

B $ and X$ evalua

te' as II0<1-2ero.

ucvever

, adding

the

till! Q$ .. ""
zero, and no' out puc 1a printed. ally line 11\1,. such as

ceuses ,,11 J strings to evaluate as Deletin!l line 1(111', or ,add10Sll1m05t

IHI F - :3
ealJ.se,s all 3 strings to evaluat.e as ncn,-:ze["o again.

If "XP'" .I.. 8" arithmetic expression involving at ring l!"pressionB logical operators, expr 1& ava luat ed by comparing the alphabl!tic the storing expressions as de te.mined bl'the ASCIl codes' .Eo'. the involved (see Appendix K}.

and Btring rnoking of chsrac ter9

®

Bef.ore patsea

THEN, to

the

Lette"

A causus

parSing

problema:

IF BETA. tHEN 2313
vRich generates a ?SYNLAK ERROR message on execution

IF BE! AT HEN'l31J

Sta'tement9 of the form 'IF e"pr TIlEtl are valid: no er ror massag," A TilEI'! iiithout

is

p1:inted. If or an tF wHhol! t a THEN wUl cause the,

.a corresponding

Theae
[I"

arl!

equivalent'

mass811"

IF ""3 TR£N 1611

?S:tNTAl< ERROR to be dUp18yed.

A-J G~TO 16(1 1F 1\-3 tHEIi GaTO 16\1
S "',><P' to used a8 exp

AI'PLESOFT' not dl!signed or intended to "11",, the IF "tatement' he s 5trin.g exprc,ssion. bur Str.ing variables and ~trings !)lay be under t.he following stringent condi tiOl'\8.

".1iI

If "xpr is II sning expression of any kind, chen \e.~p.<\ 16 non-z aro , even expr' is .list ring Val iable .. hf.ch has baan ass Lgned no value or "0" or the null 9'td:t>g, "".. I!owever the lit"ral null string',. as in If' "''' !IIEN ..• e.v,Blua tea as ze eo ..

if

76

77

fOR

1""" .. ,h •• avar set
B

FOR r ea l

aexpx l

to

.exprZ

(S'l'£P

aexpr J]

NEXT avar tile FOR are ","(!Cu ced

NEXT [avar l

[{ .avar H

\ava r\
until is

is

to 'a .."prJ \,

and che stace.me:n·ts following

NEXTavar

a statement

eoccuu te-.:"d, whet''' 8var is the same name 3.S appear s 1n rha FOR s til t.I"".llTIt. - th"n \avar\ is inc.emented by \ ..""pr3\ (\""xpd\ defaults eo l). Next \avar\ is- compared to \,,",><pr2\. and if \""ar\>\ae"pr2\,e,..e,,ut1on proc!loda \dth the sutement folLow1ng the NEXl'. I£ \avar\<-\-IIe.xj)'r2 \, ">:,,cutien proceeds from the statement .following the FOR. If \lIe."pr3\<0

Formsrhe bet to", 0·£ a fOR••• NEXTloop. When" NEXT is encounce red , tlte prog-.: m .d the c ignores it or branches to the statemen t f allowing the .. correspoll.d!IlS FOR. depending on the conditions e.xplained in. the discussion 0·£ ,the FO!!. .st"t"men~. Kultiple"vars ..ust be specLfied in the proper order so FOR••• NKlIT loops are nC$t.ed inside each other gnd do nor II("I''',OSS, ,ov'E:'!r~" Incorre.c.t.ly ordered avar s will cauae the message ?t4"Exr W1TIIOliT FOR ERROR to be prLnted.
A NEXT at a temen t in which recentlyent"red FOR-loop the same vllriable "am"· is in effect "'hen a nameless ?I'IEXl'W1TIIOllT FOR ERROR is printed. more no var Ieb Ie name. II; specified defallI t s to the most ths·t is still in effect. 1£ no FOR state .. ent; with in. effect , or if no FOR statement of any name 1s

to \avar\. following state",ent
reals, teal

t hen operation is slightly di.fferent after \ae><pr3\ is added If \avar\<\ae.xpr2\, ""eC\JUon proceeds w;ith the st~telll"nt the NEXT. If \avar\>-\a""pr2\, then ,execution proceeds ftomthc folloWing ·the FOR.

The arHhmetic.

expree ..ions s

variables.

1ote:g,ersl

mllst be " rea.! " ..riable. Hv,ar results in the
~SYNTAX ERROR me,ssage. As \a"a< \ is

the parameters of the roll. loop may be integ,e:r va_riables. Uowevett r ea l, aVliir A.nattempt to use an integ.er ""riabl.:. for re!Jl Which fom
or

NEXT is encountered

,. the message

NEltt 1<1hou[ ..va ~ ex.eout"s t

rapid ly tha" does

NEXT "Vat ..

in< ""men ted and cOOlpllred to \aex-pr2 \ only II t die bottom of the FOIt. ..•NEXTloop. the portion of the prQgre.m ills1dethe 1001' is always executed "e Leaat; once "cross" ,e.. ch other. If they do, the message

FOR.••• NEXT 1001'" "",at not 1NEJcrWlTlIOUT FOR ERROR will be pr inted.

In i.mmedlate-e><ec.uci.oll. mode, the FOR Statcment and its corresponding NEXT ata:temllnt shotdd bofh be e.xecuted i,n che s.s.me 11ne~ If a de:.Eerr-ed-exe:c:ution :FOR s:t,a.t:e.ment i.s ;B,till in effect t ,an i.m:rnedLate .... ,execut.ion NEXT stat·emen't can "aUSI!! .. jump to the de·ferred-e""cution ptogI8.m., ",here appropriate, lIo""v ..r , if che FOil. statement "a_ executed 1n immediate execer ton , II NExt 9 tatC!ment tn a dHferent i.<em<!diste- .. xecut Lon line will cause the '1SfNTAX ERROR unle.as there are no Ln tervc.ni.ng Ltnes and the N·EXfatands n lone and

U POR Loops are nested ?OUT OF MEMORY ERROR mes·8age is displayed.
70 ):"1.Jn FOR ••• NSXT loop a

",ore than

1~ l.vels

deep , the

namele,~6': JFORI-,lTO!i 1
JNEXT 2 PRIN'! I

in i",....d1:l te-execudo"IlI.ode, the POR staC'emoot Bod the NEXT..ta temen t ahou Ld both be included in ~he .a",e line, (a Ii"" Ls up to 2J·,} ehacae tel'S le"g).

un,lIT

to TO,. do no t nl10" 0 splice I.f the lener A is used immedintely prior be twe"D tile I and tlte O. !'OR I"SETA TO 56 is Une, bu t fOR t "BETAT 0 ~6 paraes as fOR I-BET AT 056 and get. " ?SYNT}J< ERROR one"ecutio(l. Each acttv" l!"OR NE>rt loop uae s 16 bytes .•. 1rt memory.

®

3 INllXT 1 15 YMT AX ERRORIN x" ""

(",,,''x

i.8

some line

numb",,)

GOSUB

Hnenu", line.
When a. RETURN BCaCement is IItl1i t.emen t 1to.med:!.a tely follOWing the

The! pr·ogt"801 branches to tile indicated )<(lcuted ,ehe program branches cocbe '"O".t r<lcenHy "><llcucedGOSUB.

78

79

Each tIme a GOSUJI is axecuced , th .. address of sL~I"lIed on t op of a !':stackH of t.hese addres.ses its way back. Each time a RETURN 0>: ... pop is t.he RETURN "s tack!1 is 't'elnoved .•

t

the follo"'ing stat'"m"nt iii :so' the p-ro.@;'tamcan latc-:r ~ hul "" .. cuted ,the top add reS!! in

I1N... GOTO old 1I1••• COSUIl def ON """p< ON aexpr GOLO lin.nHm {[, linenUlnJ} GOSUJI 11 nenum ([. Lmeuucl .. " to after the lioe

U ehe indicated lin"num does not corre.pond to aO existing t.he: e.rror messa.g,e ?UNDErn STATEKENT ERROR IN: linenam t •. g1veo, .. bere 1ioM'''" 1ndicatl!" the progr.am ~ineco"taining s ta.temeo e, The iN Lt nanum po rt Lon of [he message 1s omitted if 1s used in direct

program
the

U"",

) specified by

GOSUB

ON••• GOro b.anch 1:I... t of linenums " GOSUB

numbe,

r" thet

the GaTO, ON. COSUB worlt. ••• than a COTO 1s execu ted.

\a."pr\th in a similar
the

item in the fashion, but

casus

cl<ecutiO[lmodCl,

lcss

If \saxp.\' than

is iI Or greater than the 256. then progr.;l",el<.ec"~io"
II to

number of listed alternate line.nums proceeds to the oe.><c statement. 255 to 8v01d the
message

but

If

GOSUBs are nest·"d ?OUT OF MEliOR'! ERMR ill displayed.
Each active

mote

than 25 lev,els

deep,

the

messag,e

\ae:or.p:d \ .. ust bl! j'n the range lILLECAL. QUANtITY ERROR
of memory.

GOSU!.I (one

that

ha.s not RETllRNed yet)

"aea

.~ bytes

ONERR COTO

dor only

ONERR GOIO 11nenum RETURIl There are When an ,e:rliOr OC'CUl'B, OHER.R. COT'O ma,Y be used to avoid having an error lIIessage printed sod execuc ton halted. ,he command sets afl8g that causes an unconditional ju,"" (if an error occurs later 1 the progra.m.) to the n progrll.!!! lin .. indicated by Lf nenum, POKE 216,. II "'''setG the error-detection £1"8 so that no rme 1 error OleSSo.,g"6 will be pr 1n ted. The ONERR COTO s tatemen t mu.st be eXeCU ted to avoid pr·ogram interruption. before the eceurance of an er ror

statem.ent

no parameters or c,ptions the.t i.II!",,,diately follows
statement POP). branched

address of the (sae COSUS snd

this .o",,,,,,,,d. the most recently to is .[he top one

in

This. is a brallo;ch co cnc executed GOSU!!. The 00 the RETUR~ "scaek"

If II P rogra", encoun [er. RE1UR~ .6ra temen [5 Once more COSU·B statements, the messas.e ?RETURN IHTlIOUT GaSUl! &RII.OR

th!!.o it has

encQuntered

!sprescn

ted.

When an er ror cccur s 1'1 a pr·ollram.• the code for the "1n deciP'llll memory locatio:n 222. To see which er.rOr PEEK(.222).

type of erro ... is stored "'as encountered. PRINT

Error iii 16 Syntax

Measage fOR COSUII

NEXT without RI>TURN without Out of D.ATA

121!
133

pop There are no parll,meters or .0ptiOn& !lssoc-ia ted wi th POP. A POP hos che effect of " RE'rU-RN wIthout the b ranch, The next RETllRN encounrer ed, in$te.s.d of branching eo one s.cs temen t beyond tha !ItOS trecen tly ellecuted.GOSUB. w111 brancb toone state",ent beyond the seco"d most recently executed GOSUB·, It is called II "POP" since it pops one add tess off the tOP of the "aeack "of RETURN addte.sse8.

22 42

16) 176
191

53

69

Lil7

Overflo", 17 Out of Memory 9~· U"defin",d Statement

111".8"1. Quantity

224
2.54 255

Bad SUbge1:ipt

Redimension.ed Array 01vl~lon by Zero type Mismatch String 100 Long ·Formula Too Complex Undefined Function :Bad Response to IN PUT S t a tClllen Ctrl C Interrupt Attempted

e

If pop is axecut ed bc.fore
?IlETURN IoII,HOUT GOSUB mROR is displayed because there

a

cosue
sre

has bem, encountered,
addresses

then

the

",esaage

~

no return

on the

stack.

mullt hI:' raken when handUng errcrsthat occur ",1 thin FOR." ..,N~XT loops bet"ee" GOSUB and REtURN, a. the pointers and RE'IllR,N stacks disturbed. nUl error-ha.ndling l:outine must restart the loop, rat ur rif ng to the FOR or GaSUl! Statement, .!!5!!. the 11.BX'ror RETURN ststement. After error handling, .0 return [0 s NElITa.r a. RETURN.,i 11 cause the appropris ce p\easage: tNl!xt WI'tIlOIJ't FOR ERROR or I1UTlJRN IIlTHOlIT GOSUBE,RROR Care
(It

80

81

When OIlNERR GOIO is used .. ith RESlltlE to hand I .. e r ro r's in a GET statement, ,til" prog,r ..'" ,,1 11 "hang" if there are two t:onsecut! ve GET err or s ",1 thoutan intervening su"""ssfulGlIT. To escape. US" r eae t c r r I C returrlo 1I GCIO ends the "rIot-handling ,outi"e, everything "'orks Unc (but see next note).

""'en. "sed in TRACE Plod" Dr 1n a program cenrarutug a PR.lNI statement, ONIDUI, causes a jump to the Monitor after il3 errors lire encoun te'redWherethes!J errors, ate generated by an INPUT statement. everyth:ing works nne if RESUME IS used; but if COTO ends the error-handling routine" the 81th INPUT e"ro'~ causes " j ump ~" ehe Monl tor. Ag,ain, rese t "t r l C .. acucn 1 ge t you back. to i\Pf'LllSOFT.

w'n

If you are bothered by any of the follo"ing assembly-language
rnut Lne,

the problems subroutine

just discussed, as pan of your

"-,.e,,ute

a Ci>.LL to

cItor-handUns

to the

tJonito't,

enter enter

He" data'

68 AB 68 A6 DF 9A 48 98 48 6~ lfol4 168 1114 1M 223 1$4

or in APPL£SOFT,

Oecl",al d(l[6.:

n

152 72 96

1'0 r !!",ampLe, in APPLESOFI you could 768 zh r ough 77 7. Then yo" ,",,,ulduae tout-1ne.

POKI> the ;leclmal number s 1n to 10<.a t:l on .. CALL 768 in your "Hot-hand I1ng

It.E,!l~r IlESUME When used

of

a t the

end

of

an

er tor

hand ling

rout i ne , causes

the

'progr,am

~o

resuee execut Ion occurred. If RESlJl'lE is
will

at th" beginning of the at a tctaent

in which an error

anceun rered beforE! an at rOr occurs. the ?SYN'IAX SltrtOIl. IN6S218 "e6aog,e l!I[)y be g1:"eo, Dr other s t range even cs may t ran&pl re , program If bBstopped
Dr

Usually,

your

it "ill

"hang."
routin", Usc reset the uae of RESUME ...tl1 to escepe ctrI

lin error the

oc cur e :in an error program 1n an 1nf1n1re

hand.ling leap.

place

'c

re turn

In I,Olmed:iate'-:e:xecut:1on mode., ma')' cause t'h~ sys[.cm to "nang ;" may C9Use Q SYNTAX ERROR, or ..ay besin execut Lng an cx.lsting Dr even a deleted prostorn.

82

TEla

imm

a.

de f COl OM 6 de f

No pa rane cer s , Seta ~he SCreen to the usual full-screen text mode (411 char ect ar s per 11ne, 24 l:lnes) from low-resolution graph1~s mode or "ithe" of the two higb-re-solu ticn graphics modes. The prompt and cursor are ",(>Vec! to the la,st 11ne of the screen. If i." ue d tn tex t mode, T&lIT 1s equivslen t to vrAJI 24. statem~nt stl~h 175 TEXTILE,,127 causes execucion ? SYNTAX miteR message IIppea,rs.
A as

COLOR ~ a exp r Sets the color for plotting in low resolution graphics mode. If \aexpr\ a real , it is converted to Ill) intes"r. The range of values f o r \a.""pr\ from II through 255; these are tr"~ted modulo 16. Color: nameS blad< I tnalgenta :2 dark blue 3 purple 18 is

o

and

thair

associated

of

the

reserved

~ord

TEXT before

the

4 dark green 5 grey 6 mediuc blue
7 light to the zero blue

numbers are. 8 brown 9 orange

111 grey 11 pink

12 gre.e.n 13 yello'" 14 aqua 15 "'hite

If the text window has been Appendix J), TEXT resets to

set full

to anything screen.

other

than

full

screen

(see

COLOR
TO find

is

set out

by the GR command.
point on the in screen, use the

COLOR of II given

SCRN command.
character

GR GR

I"",,"

del

When used is placed If \lsed

in TEXT mode, on the screen in

COLOR 1s one :factor by e PLOT instruction. t ion GRaphics

determining

which

while

High-resolu

mode,

COLOR is 1 gno r ed ,

No paramete.ts. This command sets low-r"solution GRaphics m,ode (411 by 4~) for the screen, leaving four lines for text at che bottom. The screen is cleared to black. and the cursor is moved to the text "indow. Cao be conver red to full-screen (411 by 48) graphics, aIter executing GR, w.ith the command POKE -163112,11 or the equivalent command POKE 49234, (I If GR follows a full-screen POKE command, mixed GRap'hics-plus-text mode is rese.t. Ai ter a GR ccamand , COLOR hae been ae t to z er c ,

I.or

I .... A dd

PLOT ae.xpr 1, se.xpr2 In low-resolution graphics \aexprl\ and y-coordinate the mOSt recently executed specified) • mode, this command places a dot ",ith x-coordinate \aexpr2\. The color of the dot is determined by COLOR stetement (COLOa-1I if not previously

\aeKpr 1\ mU8t be in the range 0 through range (I through 41 or the message ?!Ll,EGAL QUANTITYERROIl appears. of a variable name,

39,

and

\ aexpr2 \ muSc be 1n the

U tile reserved word GIl is used a. the first the GR may be ~e"u ed ~ you get the ?S\'NTAX ERROR message. Thus, execucing the Gtatem~nt

ehaeae cet-s

GRIN .. S
leaves you with an unexpectedly darkened Screen.

An II t tempt to PLOT while the ays tem 1s 1n TEXT "ode, o,r in m1><;"d GRaphic:s-plua-ce><' mode wieh \a"xpr2\ in the rang" 1,0 to 47. wU1 "esult " character being placed where the colored dot would hove appeared, (A character occupies the space of two low-resolution graphics dots stacked vcrtlcally.) The command has no visible effect when used in mode, even if preceded by a GR command, as the the low-resolution graph:lcs portion (page one) The orig1n se ecen , (II,~) for all graphics 1s in the

tn

If tssued whUe HGR is in effect, GR behave" normally. However, 'if iIIsued whUe HGR2 is in effect, CR clears its usual screenful of memory, but leave," you looking at page 2 of low-resolution graphics and text. To rerurn to normal mode, simply type TEXT. In programs, uSe TEXT before switching from HCR2 to GR .•

~

HCR2 High-resolution graphics Bcreen i8 not "looking at" of memory. left corner of the

upper

84

85

JiLlN

I""" l. de!

seRIO

~ def aexpl:2) mode, the function SCRN returos the is \ae xpr I\ and "'hose y coordinate color code of is \aexpr2\.

HLIN aexprl,

aexpr2 AT aexprJ
by tli

SCRN (aexprl,

Used in lo"'-resolut1on GRaphics mode, IlLIN draws a line from (\s"xprl \,\a"."pr3\) to (\a""p,,2\, \ ae op:<3\). The color is determined
most recently exec.uted COLOR statement.

In low-resolution GRaphics the point whose x coordinate

\aexprL\ and \aexpr2\ must be in the range 9 through 39, and \aexpr3\ must be in the range 9 through 47, or the ",esaage ?ILLEGAL QUANTITY ERROR appears. \aexpd\ may b" gr"ater than, equal to, or less thao \aexpr2\. If IlLIN i. used when the sys tem is in TEXT mode, or in miJ<ed GRaphics-pIus-text mode with \aexprl\ in the range 41j1 through 47, then s line of characters will be placed "here the line of graphic dots would h,IV been plotted. (A character occupies the space of tWo low-resolution ,dots stacked ye~tically.) The command has
mode.
Note that the I'IU" "in this command refers DO

viSible

effect

"hen

used il'1 high-resolution

graphics

AI though 10 .. -resolut10n GRaphi.cs plots points at serum positions (x,y) "here x is 1n the range III through 39 and y is 1n the range 0 through 47, the SCRN function accepts both x and y values 1n the range 0 through 47. Uow~ver, if SCRN is used with an x value (\aexprl \) in the range 4il through 41, the number retl>rned g Lv .. the color at the point who." x coordinate is s (\""xpr\-4!J) and whose y coordinate is (\ae><pr2\+16). If (\aexpr2\+16) is in the range 39 chrough 47. ill normal mixed GRaphics plus text mode, the number returned by SCRN is related to the text cha eae cer at that position in the text area below the graphics portinn of the screen. If (\aexpr2\+l6) is in Ile range 48 through 63, SCRN returns a number unrelated to anything on the screen.

~

"high-resolution". high-resolutiOn

BlCcept for instructions.

co "hcz Laon ra L" and not HL1N and HTAB, the pref:1x I'H" 'refers

1;0

1n TEDITmode, SCRJiI r e turna numbers in the range II through the upper four bits, 1f aexpr2 is odd; or lower four bitS, if aexpr2 is even of che character at character pos1tion (aexpr 1+1, lNT «aexpr2+1) So the exp reae Lcn
CIlRHSCRN (X-i, 2· (V-I) )+16"5CRN (X-I, 2"(\,-1)+1» w1ll return the che eae ter at character position

15 whose va.Lua is

/2».

ex., Y).
to is a

VLIN aexp~l, aexprZ AI aexpr3 In low-resolution GRaphics mode, draws a vertical line from (\aexpr I. , \ \Ilexprl\) to (\oexpr2\, \"expr3\). The color is determined by the most recently executed COLOR statement. \aelllprl \ and \aexpr2 \ must be in the rang" the range 0 through 39, at the message is displayed.
\lle.xpr2\. ?ILLEGAL QllA.NTlT\, ERROR \aexprl\ may be

In High-resolution

"",de, SCItN continues to "look at" the low-resolution GRaphics area, and the number SON r e r ur ne is 110t related the high-.resolutlon display.
GRaphics

SCRN is

0 through 47, \aE\xpr3\ must be '1n
equal to,
or

parsed as a reserved left parenthesis.

word only

if the next non-space

character

greacer

than,

less thon HOR
No

def

If the system is in TEXT mode when VLIN is used, or in mixed GRaphics-pIus-text with \aexpr2\ in the range 1i0 through 41, the portion of the line .. thin the te"ta~" 1 a ,,111 appear 89 8 Un" of c:ho,<acters, placed where the graphic dots would have been plotted. The command has no visible mode.
"U",ct

when used in high-resolution

gl:aphicB

pacameter9. Sets high-I:caolution graphics mode (28~ by L6~) for the sc eeeo , le av Lng four lines for t ax ]; at the bonom. The screen is cleared to black 3nd ~ of ~emory (BK-16K) is d!spiayed. HeOLOR is not changed by this command. Text screen memory is not affected. Use of the HGR command leaves the teM t ""'indo,,"at full screen, but only the bottom four text Lfnaa orevlsible below the graphics. 'The cur ae r w.ill still be in the ccxt "wi nd but may not be visible unless it ls moved a one of the

0"" , ..

bottom

I,

lines.

86

87

The screen can be convened to full-screen ""ecut in& KGRwith the POKE cOI1lttl8nd
POKE -If>31!2. II the use of POKE 49234.1il wl11cb is equivalent. mbled h1gh-n,.elution
'Or

(211(1 by 192)

grsphics

after I!COLOR - aexpr

If HGR fo11owsaeithe, ,graphics-plus-text

is

of the reSet,.

above

POKf) commaod.,

Sets high-Tesolution graphiC. IICOLOR, whlchrrust b .. in tbe

color to th" t spec if1ed range II to 7., il',,1us1ve.
4 bla<:k'2 5 (depends 6 (dep",,,ds 7 wh1te2
on on

by

the valu.e of Color n.. me. and their

associated

If the reserved word HGR is used as the firs t char acteeS of the HCR ..... y be executed before the ?SYNTAX ERROR --message appears. Thus, execu ting[he s'ts tement HGRIP-4 results [:0 an unexpected trip into high-resolution graphics er3.e your pl:ogram.

"'8" "'!i'"

o

valuessr

e

a varia

b~" nntn ,

black! ( gn~en. (depends On TV) 2 blue (depends on IV) 3 ",bitel

TV)

Till

®
mode, \.Thieh may

TV",,,,ork-.-·-·

A high-resolution dot plotted with HeOtOR-3 (.mite) will be blue if the ,,-c;oordinate of the dot .is even, green if the J<-eoordinatO! Ls odd, and white only if both (".,y) and (><+1,yl are plotted. This is due to the w",y home

A very long par'tiallyerased

pr,ogram which extends above mcroory l<)c<I(ion 8192 my be when you execute tlCR. or it may ",,~1tc" into YOUT page hi.gh-resolution graph1,cs display. Ln p a r t.Lcu Lar , string data. 111stored at the .!..!!..I!; of memory; onsm,,11 memory systems (L6K o r ZI!K) this <lata ma.y r e sf de in page 1 of high-resohnioll graphics. Se~ HIMEl1: 8192 to pro teet you.r program "nd pase 1 of h1sh-resolution gr"phics.

HCOLOR 18 no t changed atatem"nl is execured indeter·mina te.

by IIGR, HGR2,
, thl! 1'1,ott1ng

or RllN.,
color for

Un til the f1rs h1gh-resolution

t HeOLOR graphic;,.

1s
color

If used "h.ne in being displayed.

low-resolution

GRaphlc~,

H.COLOR does no e a.Hect tne

11G~2 [""" ElGR2

• de! HPLOT "ex I'r 1, aexp r2 HPLOt TO ae"pr3, ae"pr~ IIPLOt aexpr 1, aexpe2 TO a""prJ, This HPLOT ..tth

a"Kpr~ ({TO aexpr , aexpr H

commllnd sets full-screen high-resolution graphics mod.o The sc;reen is cleared to black. and ~ of memory (l6K-24K) is dlspl,ayed. Te><t Screen memory is nc t sH·ected. Thispalleo£ memery {and therefore the c;ommandIiGR2) i.8 not ava:llable if your .yetem contains less thsn 24K 0 f ml!mory. On sys [emfl tha t de sHow it, using HGR 2 instead of HGR maKillliteathe me·"ory apace available for programs.

No parameters. (281! by 19.2).

the first option plots a high-resolution dot whose x-coordinate b \Be"pr I \ and whose y-<:oord.inl!te is \ae><pr2 \. The ~Dlor of the dot is determined by the lIlos,t recen clyel<ecu ted HeOLOR 8,t8 t eman e , The value 0 f ReOLOII is 1ndetetminate if notprI!lIiously specified. secQndoptio'n causes a Line to be plotted f~ol!l the last dot p l o t t cd to \aexpr~\). The colo. of thia Hne 1s clcecrndned by the color of the last dot p Lot.t.ed, even if the va.Iue o,f HCO.L.OR has been ehang.e<l since the prev100s plotting. If no previou.s point has been piotted. no line i. draw".

The

On 2~K systems
graphics

set HtHElM: 16)8" to protect page 2 of high-reso,lution hom your pro,gram (especialty s~rings, which are stored at the
c"

(\ae><prl\,

!££ of memory).

If the reserved "'o~d flCR2. is used as rhe first name , the HGR2 may be ""ecuted 'b<l_f_c>'r". the ?S'mTAX ERROR mes'sage i9 giV'en~, Whe.n exe.cuted t a :st.atement

"haracter"

in

a v ".riabl"

such

ns [I!aches of the

14" IF X > 1511 THEN 11GB. 2PIEC8S .. 12 Laavea the Screen auddenLy blank. possibly p rog·rllill erased.
The conmand

.. 1 th

thl! upper

option 1& used, II line Erom (\sexprl \, \"."p.-2\) to (\""xpr3\, is plotted using the cc Lor specified by the most rec:erH HeOLOR c:ommand. The plotted 11ne .. ay be e.xtended in the "arne instruction 8.1m.09t indefinitely (s"bjec;t to '[he screen limits and the 239 cnaraccer i".tru"cion limit) by e.xtending the 1nstl'uctiQnwith T1) o O1><pr, aexl'r6 5 TO aexprn7, lIexpr8 and so on. The Single ststl!ment H1'L01 !,l,1a TO H9,~ TO 279,159 TO 0,159 to O,0 euo plot a rectangular border sround all fOUl s,ides of the high-resolution ac r'een, If third

\a,,><pr4 \)

POK£ -1 f>3!,l1, II
mode.

converts any ful '.-screen. gruphlcs mode to mixed graphics-plus-text Whcn is9u.ed a.feer HGR2. how" ...er , the four' l:tnes of text are taken 1. of text. which is ne t ,easily a ccessiblc to the us'er,

fro," £.!!..II£:

89

88

HPLOTmust Inclodlng

be preceeded your prolp:alll

by and

!lOR or HGRZ to avoid v.... l ..bles,.

clobbering

Lnr e of

memory,

\ .."",prJ\ and \8""prJ\ mus~ be \ a""pr2\ and \"""pr4\ aruS~ be \oe.xpri \ m.ay be g'reacer than, be grea tel: than. ,equal to. or
An

in Ch" r.ange 0 theough 279. 1n the range II tb eeugh 19L equal to, or 1e'8 than \ ..""pr3\. le"" than \.,,,,p[4 \. thes"

\aexp'[2\

1M)'

lDesssge,.

at t empt to plot a ,point whos" coord1m:lces "xceed HLLBGAL QUANTIH ERROR U the Screen is in mf xed high-resolution t ..xt , then att".mpts Co plot poIncs ..-lth y-c.oordinatea through 191 will have no visible "ffee e ,

1imies

causes

tho

graphics in the

p.Lus 4 11n". of range 16~

I'l>L {aexp r ) Th!s function ,,,tu[na the curren~

(or PaDdLe) sp(H:ified by \aexpr\, The game eont nc l, is a resistllnce
If two galDe controls

val ue , h:om'~ to 255, oE the SalOl! control 1£ \ae"pr\ 11' in the range II ~hrou8h 3. variable hem iii to 15(1K 01\1119.

ar,e 'tend in eonsecuti"I!PDL mat ruc.rf.one , the rea.dtng from the second gam" control may be "ff,ected by the ,eBding, froln the firat,· 1:0 obta.in m.oreaceurate "e"dings ,allow sClre.al program linea between l'DL
insnu.c'tions, inStructions". or p Lace a short delay loop (FOR 1-1 1:.0 IIJ:NEXT I) betw~en 'PilL

n

\aexpr\

is l'Iegative ol: greater
ERROR

than 225,

the

QUANUT'i mes'sage is given.

HLLE{;AL

H \"""pr\ is in the r ange A throu!!" 255, the E'DL function return", .. rather u "predictable number fro ... " to 255, and may cauae various side affects ,90mo of ...Idch may dl.aturb program "><,,cut'lon. For :Ln,,~an"", if \".... pr\ is inth" range 2il4 to 219, USe of th ... POL function 11' frequl!ntly and ratller randonlly accompaniod by a "'click" from thl!
computer's, spe.a.k.e['.

If N 1s in [he rnnge 236 through POIQ: -I ,6S40t+1. (I 50 chn t POL (236) rnay se t GRaphics App~ndb J).

239,

POL (N)

may result can

in

6

mode , PDL (237)

"" t TEXT mode ,. etc

(see

Innddition to tl>adlng che settJ.og90£ 4 ",ar:l.aI>1" game controb usfng APPLESOFT can read the stllte of 3 811me buno"" (on~off "",i rchea ) using various PEEK comlMnd., lind can turn on snd off 4galnc road-outs (TIL "wj tcheB) using var teus KlKE com... nds (SCI! Appandi" J).

P.DL,

90

HOW TO CREATE A SHAPE TABLE
APPLBSOFT
has five special commands "Ibleh allow you to man:1pulate shapes 1n high-resolution graphics: DRAW, XDRAW, ROT, SCALE, and SRLOAD, BeEore chC.l$ APPLESOFT commands can be used, a shape mus C be defined by II "shape definition." This shape definition cooaiets of a sequence of plotting vectocs that axe scored in a series of bytes in APPLE's memory. One or mor~ such shape definitj,ons, "lith their :index, make up a "shape table" that can, be created from the keyboard and saved on disk or caueue tape, for Eutu~c

Suppose

you waot

to draw a shape like th:is:

•••


Fi:r,8t: t draw i,t dot per square.
0[1

• •••

graph

pape r ,

erie

Theil decide to start drawing the shape.

where

Let's

use.
byte in a shape definition is divided into three sections, and each sectiol> can specify a "plotting vector": whether or not to plot a poin • lin!! also a d Lrec t Lon to move (up, down, left, or right), DRAW and XDRAW stop through each byte in the shape definition section by section, from the definition's first byte through its last byte. When a byte that conrains all zeros is reached, the shape definition 1s complete. Each

St9r~ this one at the ceDter~ NextJ dra~ a path through each point in the shape, USing only 9P degree angles On the turns:

Ibis
byres

is

how the three sections A, 8 and C flre arranged that make up II shape definition: Section: Bit Number: Specifies; D

.,i thin one of thl'.

1
Now IIu:nwTap" those vectors

I

the shape as a series of plotting vectors, each one moving one place up, down, right, or IeEe, and distinguish the vectorS that plot a point before moving (0 dot marks vectors that plot points). Next, te-draw

&I
line:

c

8

A

and W"t:ite them i,n .9 straight

1~7 __~6~~~4
D

POD

__

~~2~~~~~1
POD
Next drsw a table like the

one in Figure

1, belo~:

or II Hove ) Only

whether

Each bit pair DO specifies II ditect10n to move. and each bit P s~ecifie8 or nOt to plot a point before moving, as follows: H DO Iftl move - ill move .. 11,1 move .. Ll moVe
B

Section C
Byee

up right dow left

st

If P ~

(I

.. 1

don't
do plot

plot

I 2 3
4 5 6 7

-

Notice that the lastsectton, C ([he t"lo most sign.ificant bits). does nor have a P field [by default, p.~), 90 section G can only specify a move "1th~ plotting. Each byte can represent up to rhree plotting vectors, one in sect:lon A, in section B, and 8 third (8 moye only) 1n section C.
01'0

-~ ~
I

1. 1.
I

B

A

C

Vector

Code
\111'11

~

(101 or 01 (110 Or HI
(II

an

8 9

1

-

; ;

HI~
lill

119
111

):.::

..

-Deno

teS '-En-d,----------" of Shape Defjnl tion

LThis

Vector

_j

DRAW and XDRAW process the sections from r1gh to left (least significant bit to .. osc Significant bit: section A, then B, then C). At any section in the byte. IF ALL THE REMAINING SI1C'I'IONS OF THE lIITE CONTAIN ONLY ZEROS, TIIEN THOSE SECTIONS ARE IGNORED. Thus, the byte cannot end with II InOV" in 8"etion C of gO (9 mOve up, without plotting) because that section, conca .n1ng only zeros. "ill be ignored. Similarly, if section C is 0i1 (ignored). then section B canno c be a move of 0~il as that "Iill also be ignored. And a move of 0gg in section A will ~ your shape definition unleS8 there 1s a I-bit some"lhere in section 8 or C.

Cannot Plot Or nove Up Figure 1 For each vector in the line. detenaine the bit code and place it in the next available section In the tablo. If the code will not fit (for examp e, the vector :In "eetion C can't plot a point), or is a 011 [or ~tJ0) lit the end of B by te, then sk"i p [ha t sec t Lon And go on [0 the ne Kt . When you have fill lohed coding all your vectots, check your work [0 make. sure it 15 aceu" t.a ,

92

93

Now make. anot he r t:abIe~ as shevn in Fig,U'l",e 2t be.lowt and :re..... copy the V'{H~tar codes ft,old the -first eab l e , R"""de the vector information into a series of hexadecimal bytes, using the he.xadecimal codes from Figure ].

By·te S+II +l +2 +3
+-I;

n

(!II to :FF')

Unuged
Lo'wl'er

'----'otal
DI, D2,

-2

Number of Shape Definition" By re 0 f Shape Rel>!Uve to $ Byte of Shspe Relativ" to S

Ul>p.",
L,o-..;re:1'

Section:
'Byte

"

II II Ii Ii II I' 1 ~ II I ! I I I ! 2 (I il II Ii ~ J ~ .l (! Ii· II 4 II 11 ! (i I iii I 5 II II .Ii! I II II I 6 IJ I,l I 1 Ii 11 7 II I,l ~ 1 I I II II; ~ ~, Ii II t 1 I 8 (I i1 (I 9 IJ II II II iI

-- ,,_.._ ---,
C
B

B.ytes Recoded :In Hex

Codes Bin!lty Hex

Index

+5

Upper

Digits 2 Digits 2 Digits 2 Dlgi·ts

Index to; Pi r sr DeUn.! don ~I, Index to Pirst Definition 92,

"

""

I2 JF

~1I(l1I
1111111

II
]

2 (I' 64 2D

~1I111 111111
ill II"
lilllIl

1 2 4

+20 +2n+1

I

Lower 2Dl1'\Hs Upper 2 DigHs Fitst Byte

I
} }

On:

Index

to

Definition
Shape

Pi rar 8n,

By te of Relative

Shape to $

S+DI

15

Rex."

---

IE II 7

36

IIll\!
l(ilU

o

.._",._.

Digit 1 Digit

IJ .... Denote. End of Shape
Definition

0111 1~1iI1I UIH! llIli 1101 111(1

5 6 7
8

Definition

'I

9 .. A

Shape

O .. nhion U

12

Shape
Da{:ln1

2

1l~1I Llll

•D
E F

B C

ti~""

F:lgure 2

S+Dn

Fhst
Last

8Y~}
61' [e-011

Sltspe

Definition

~n

Figure' "eries definition.
Ihe

2 is d'leahnpe There 10; still" little more infor:tlUlt:!on you need to p'rov1.de before you have !I complete shepe table. the f.orm of. the shape tabl e. cpmp Le t e "i~h its Inde~,. is sbown in Figu"e q On the n ..xt, pa.8e.
bytes Fo~ this exarnp Le , your index :hessy' there ls only one shape <lafini.cion·. The .hap. table's 9ta~tin& Iocat t on , whose address "e have ca Ll ed S, muB.t contain tile number of shape de.finitions (between 0 and 255) in hexadecimal. In this. case , that numbet :h just one·, We "ill place Out shape definiti·on loJllICd1ately below the index, for .simplicity. that means, in this case ,the shape d·"Bllleion w-HI start in bY'ce S+4, the address of shape definit1on!!L, relative to S, is 4 (II~ 1,14, in hexadeciIBd). Therefore, 1nd.eK byte S+2 II)US[ contain the value 114 and index byte $+3 must contain the value Il!i. Ihe completed shape table fo[" this .xample is shown in Figu~e 5 on the next Stan (Sto re add ~e.SS In 1':8 an.dS9) 8yte

of hexadecimal

ehs e you acriv ..i at inns"re <

"
I 2

Number of Ind"x to

Shapes

J
4

IZ
3F

Shape Definition '1, Relative ~Q Start

<'--P.i r s t By t"

5
&

page.

7 8

2tJ 54

an
IE

Shape

De fi nHion

11

9
A B C D

15 36

07
111,1 +-L"st Byte

Figur!!

5

94

95

You are no'" ~e dy to type the shape table a into APPL.E's memory. Fiut, choose a starcing address. For this example, we'll uSe hexadecimal address WFC. (Note: this address must be less than the highest memory address available 1n your system, and not in an area chat will be cleered when you use IlGR or HCR2. Locn t Lon toFC is ju&C 'below the high-resolution graphIcs page !, u sed by 1JGR.) Press the RESET key to en teethe Honi tor p,rognm, and type the Sterting address for YOUT shape table: 10FC if' you press the RETURN key now, APPLE w11l .how you the address aod the contentS of [hac address. That is how you e"amine an address to set! if you have a put the correct number there. If instead yeu type a colen (:) followed by a two-dj_git hexadecimal number, that number will be stored at the specified address "'hen you press the RELURN key. try this: IDFC return What does A~PLE say the contents of location LOPC are? Now try this: 10FC:"1 re.turn IDFC returll lDFC- ~l The A:PPLE nov BayS that the value 01 (h"xad.,<:imal) is stored in the lcuation whose add r-as s 1s lOre. To. tore mo ra two-d1 git hexadec.imsl numbers 1n suceeas ive bytes 10 memory, :lust open the first address:

SAVING A SHAPE TABLE
TO

sa""

1) 2) 3) lrem ), able, digits): 0:GD

your shape table 00 tape, you need to know Starting address of the table (LDFC, d.n our Last 8.ddress of the t.ab.Le (lE~9, in our 01 Ue'rence be tween 2) and 1) ((ilIl(ilD, in our the difference be~een the last address and muse be stored in hex locations II (lower two

t~["e

things:

examp Le)
exa.mp.l.e) exemp 1e) the first address of digits) and 1 (upper the two

IlIIl

return

Now you "an "W<it,," ..tored io Leca t.f ous in locations Starting 0. IW !DFC. LE09W

III

(store on casae c ce I fjrsc the table length that to 1, and then the shape table its e, lf that is Address th:cough Last Address:

is stored

iorc:

and

rhen type

the numbers,

separated

by spaces:

Don't pr eas the .RETURN key until you have put a clIssette in your tspe recorder, [t!,",ound it, and started it teeording (press PL.AY and RECORO simultaoeously). Now press the computer's RETURN key. To use the tape. now) rewind type I t , start it playing (press PL.AY), and (in

IOFC:01 You bave To check separately interest

~Q O~ O~ 12 3. 2~ 54 2D 15 36 IE ~7 O~ return
JUSt typed in your the information In or simply press (and a few extra, first complete shape table ••• noe so bad, was 1 1 your shape table, you can examine each byte the RETURNkey repeatedly until all the bytes of probably) have been displayed:

APPt..£SOFT,

SHl.OAD return You should successfully, hear one "beep" when ehe table's and another "beep" when the length has table itself been read has been read.

LOFC r e curn LDFC- III * return

*

illl (14 illl
('E!tuX'n

USING A SHAPE TABLE
'tou are now ready to wri'te an APPI..ESOFTprogram command" DRAW, KORAW, ROT and SCALE. using

lEOIl- 12 • return

3F 2116~ 20 15 36 IE

tile shape-table
defined shape, rotate than the One before.

1E08- ~7 ~~ or IE 23 0~ 0~ F'
shape table looks correct, all thst re~atn& 1s to store the starting address of the shape table ~here APPLESOFT can find it (this is done autolllSt1c:ally when you use SHLOADto get a table from cassette tape) . APPLESOFT looks for the four hex digits of tbe table's starting address in hex locations E8 (lower two digits) and E9 (upper two digits). For our table's starting address of 10 FC, this ,",Quld do the trick.

I~ your

Her"'" II aamp Le APPLESOFT program that wtll print our it 16 degrees, lind then repeat, each repetition larger

211
3(1

III 411
5(1

HGR HCOLOR

1
R

3

FOR
SCALE

R-

TO
139,

ROT -R DRAW I AT IIElIT R

5"
19

E8:rG

10 r acurn erased by your APPLESOFT (in hex locations 73 and

60
7(1

To pr or ec t your shape table from being accidentally program, 1 t ml.ght also be a good idea to set IIlHEM: 14) to t~e table's starting address. 73: FC !D This tao is done automatically

'fa see a. single "eque r e" I add a line 65 ENO "0 pallse and chen "rase each square after 63 FOR l-q TO 1(1(1(1, NEXT I 65 XDRAW I AT 139, 19

it

is

drawn

add

these lines:

when you uSe SHLOADto

gec

the

cable

from

c.aase tee rape.

96

97

RT ORA~ a~xprl AI 8expr2, DRAW aexp r L a"xprJ

I

t\

"

deE

ROT .. aexpr S til "".gula.r rotation roCation 1s specified for shape to be drawn by DRAW or XDRAW. The "mount by \aexpr\, .. bieh m.ust be between 0 to 255.
of

ORAI' ...th the first option draws" 1 shape f n high-re90lution grapld..CH starting at the p010.t whose ,,-coordinate is \8ex1'r2\ and whose y-coordinatc is \a""prJ\. The ahape drawn is the \aexprl \th shape definition in the shape table prev10uBly loaded uBing the SHLOAD command (or a ahape table may be t)'ped into the APPLE's memory in hexadecimal code, using the Mon'itor program) • \8exprL\ muSt be in the cange G through through 2;5) of shap" definitions given \aexpr2\ must be in the Cange 0 through through 191. If any of these canges is ?ILLEGAL QUANTITY ERROR ~ill be displayed. n, where n is the number (from ~ in byte ~ of the shape table. 278. \aexpr3\ 1n the range II exceeded, the message

ROT-a will cause the shape to be DRAWn oriented just as it was defined, ROT-l6 will cause the shape to be DRAWn rotated degrees clockwise, ROT-32 will cause the shape to be DRAWn rotated 18g degrees clockwise, etc. The l!rocess repeara starting at ROT-64. For SCALE-I, only 4 rotation values are rneogn1zed (a,16,32,48); for SCALE:-Z, 8 rotations are recogn.ized, etc. Unrecognized rotation values ... cause the shape to be DRAWn. with the 111 orientation of the next s....lle. (u8ua.lly) r ecogn Lzed rotation.

9a

ROT

parses as a reserved

word

only

e piilee ... n t s1go e

if the next non-space

charac.ter

is the

( • ).

The color, rotation and Beale of the ah ..pe specifi ed befo re DRAW is execu ted.

to be dr .... must hav .. b'''.n "

~C"Lt SCALE

1.... " dn t - sexp"

The second option is similar to the f1<st, but draws the spec:lfied shape. starting at the last point plotted by the most recently executed H~LO~,

DRAIJ, or XDRAU <;ommand.

'I' If issued

Sets scale size for shape to be drawn by DRAW Or XORAW to factor from I (point for point reproduction of the shape defjnition) to 255 (each vector extended 255 times) as specified by \aexpt\. NOTE: SCA~E.a is ma"loo.m size and not a single point. SCALE parses as a re.served word only if the next non-space replacement sign ( - ).
SIIL.DAD I mm " dc E

when there is no shape table in the computer, may cause tbe system to "hang." To recovar , use reset c t rL C return. ~Iay also draw random "shapes" allover the high-resolution graphics areas of memor)" possibly destroying your program, even if you are not in graphics mode.

charHcter

is the

XDRAW

[rom' def aexpr
J]

SliWA»

XDRAW aexpr l [AT aexpr2,

This command "is the. same as DRAW, except that the color used to dr8w the. shape is the complement of the color already existing at each POilH plotted. These pairs of colors 9r~ complements: Black and Whl ee Blue and Green The purpose of XDRAW is to provide Sn essy way to erase: if you XDRAW a shape. and then XDRAW it again, YOU'll erase the shape Without erasing th background.

Loads a shape table from caSSette tape. Shape table is loaded just helow IIIHEH: and lUMEM: 19 set to just below the shape table to protect It. The uhape cable's starting address is given to Al'PLESOFT' 9 shape-drawing routinea automatically. If a second shape table is loaded, r ep.l acrng the flrst table, HIMEl'!: should be reset prior to loading to avoid wasting III .. ory. Shape table tapes are prepared using the lnstrunions at the beginning of ~hi8 chapter. On 16K systems, HCR cIe"rs the top ilK of !!Iemory. from location 8192 to location 16383. To force SHLOAD to PUt the shape table below paSe I of IILgh-resolution graphic5, set IIIMEH.8L92 belote executing 5HLOAD. On 24K 6)'5tem~, do not use llCR2 ("hich clea~6 memory from location 16384 to

$cautionary See

remarks

for DRAW.

98

99

Locat I Oil 201 75). or else se t H.litEM: 6]81. before SIlLOAD and do no [ US'" HC)l... 5 1 If you are sure there is enough safe ",,,mocy above lo"ation 24515 to hold your shape table ,[here is ""thing, to "0 rry about , 'Cnly rese t can in te erup t SIllOAD. If the variable nama, the rese rved-we rd command ?SYNTAX ERROR is given. Th" StMemen[ SEiLOADEII: 59
B

reserved
may he

"0 cd

execut.ed

SIlWAD begins hef O,Ie an)'

II

hangs the "ystem, ".SSe t te racorder

,

"h1.1,,, APPLESO:I'T "airB Use r eaet c tIl G to

indefini tely f.or iii. pr ogram from the regain con t r01 of the computer.

100

BUILT-IN FUNCTIONS
lUi functions .... y be used whe.rever an egpression of the same type may be used. They may be used in either immediate or deferred execution. Here are brief d"sctiptions of some of APPLESOFT's arithmetic functions. Other functions are described 1_n sections d" a ling "'ith similar Lne t ruc ti.ona. Slit (aexp r ) Re rur ns the sine of \aexpr\

I~ I

(I.

<prJ
(!

RoIs~9
I • (l,

(to 6 places.

e~l. 7L8289)

to t he indicated

povar , \aexpr\.

'pr I

R (ucns the natural

logarHhm

of \aexpr\.

radians.

cos

(aexp r )

Returns

the COS1ne of \ae><pr\ radians. of \aexpt\ radians.
The. angle re.turned is in

DERIVED .FUNCTIONS
nIl'

T,\. (II~Xpr) Returns the tangent

"'T~ ("""'prj
Returns

following functions. wbile not intrinsic to APPLESOFT BASIC, can be calculated using the existing BASIC f unc t Lons and can be easily Lmplemeoted by using the OEF :f'N f unc t10n.

the arctangent. in radians. of \ael<pr\. the range -pi/2 through +pi/2 radians.
!tIT
(.l'~pr)

SEOANT:

SECCX) • IfCOS (X)
integer
Le.... than or

Return .. the largest RND (al'xprl R"turns a random

equal to \aexpr\. or equal to il and less than 1. [;OSECANT: CSC(X) • L/SIN(X)
COT AIle ENT : COT(X) • If TAN (X)

<<'al number greater zero.

than

l.f \a""p,\ is greBte.: than each time it is used.

RND (aexpr ) gener a res a new 'random number

If \supr\ 1s less than zero, RNO(aexpd generates the Same random number eacb t1me it is used liith the same \ ae.xpr\. as i.E from a permanent random number table built lnto the APPl.E. If II part.icular negatlve argument is used to &e""rate a random number, then subsequent random numbers generated with positive arguments will follow the aame sequence each ~im.e. A different random sequence is initialized by each different negative argument. The p rL.... reason for usi.ng a negative argument for RND is to ry lnitlall:>-e (or "seed") a repeatable aequenc.e of random numbers. This is particularly helpful in debugging programs chat uSe aND.
If \aexpr\ is zero. RNO(aexpr) retUfns the most recent previous random number gen"Tated (CLEAR and NEW do not affect this). Sometimes this 1s easier thon assisoing the last random number to a variable in order to save it.

INVERSE SI~&: ARCStN(X) • ATN(XfSQR(-X*X+ll)

lNVERSE COSINE:
ARCCOS (X) • -ATN(X/SQR(-X.X+I»+1.51118

INVERSE SECANT: ARCSEC(X) • ATN(SQR(X*X-l»+(SGN(X)-l)*1.!i1118

seN (II 'xpr) Returns -1 if \aexpr\<il.
AilS ("clIpr)

INVERSE COSECANT: ARCCSC(X) - ATN(1/SQR(X.X-l»+(SCN(X)-!)*l.51gS lNVERse COTANGENT: ARCCOT(X) - -ATN (Xl+L

returns"

if

\a"xpr\~il, and returns ie. \aexpr\

I if \aexpr\>II.

Returns
-\aexpr\

the absolute value of \sexpr\ iE \aexpr\<g.
root. this

if \aexpr\>-il.

and

57gS

SQII (.I('X!>r 1 Returns the positiv.e square

1" a special

implementation

that,

HYPERBOl.IC SINE: SINH (X) • (EXl' (X)-EXl'(-X»

12

executes

mOre quickly

than -.5

102

103

H,{PERBOLlC COSINE: COSH(Xl ~ (EXP(X)+EXP(-X)1/2

HYPERBOLIC TANGENT: TANH {Xl - -ElO'(-X)/(I>XP(X)+EXP{-X)

)*2+1

HYPERBOLlC SECANt: sECH (Xl ~ 21 (IlXP (JO+EXP (-X) )

HYPI>RBOLlCCOSEeANT: eSCll (X) 2 /(EXP (lO-EXP (-X»
B

if'i'1'ERl>OLtCCOTANGENT; eOTH (X) - EXP (-Xl I (EXP (X)-EXP (-X) )*2+1

INVERSE HYPERBOLIC SINE: ARCSINH (X) .. IJOC(X.+SQll(XNX+l

J)

INVERSE HYPERBOLIC COSINE: ARGCOSH{X) .. LOG(X+SQR(X"X-I})

INV<;RSE: H'fP<;RBOLIe TANGENT: ARCTANH (Xl. LOG ((l+l\)!( i-x: }/2 INVERSE IIY.PERBOL tc SEC MIT : ARCS EC II (X) .. !..OG«SQ&{-X"'X+I)+I)/X

INVERSE ilYPERIlOLIC COSECANT: AIlGCSCH(X} .. LOG (SGN(X)'SQR(X*X+I)+1

) Ill:

INVERSE HYPERBOLIC COtANGE"NT: ARGCOtH(X) .. LOG «HI )/(X-l»

n

II MOD ]j

MOD (II) .. INT«II/B-IHT(A/B»*a+.p~)*SGH(A/B)

Appendix A: GeHing APPLESOFT BASIC Up And Running
APPI..E Computer Inc. offers two versions of the BASIC programming language. Integer BASIC, described in tbe APPLE U BASIC Programming Ha.nual, is a very fast BASIC suited for many applications, especial.1y in aducatLon , game play:1ng, and graphics. The other version of BASIC is c.alled "APPLESOFT" and is be t t ar auited for most business and scientific. applications. APPLESOFT BASIC ia available in two versions. Firmware APPLESOFI comes with APPt.ESOFT in ROM on a pr Lnred circuit. card (AP.PLE Pan Number A2.B0!11l19X) wh.1ch plugs d.lrectly into the APPLE n. With t.h Ls opLion, the flick of 0 switch Bnd two key-strokes start the 111'I'LE running in APPLESOFT. Aside from this convenf.ence , hev Lng APPLESOFT in ROM saves a.bout l!1K of ,. ..",ory and Saves much tLroe loading tbe language in at every use, from a cassette tape The main body of [his manual aSSumes you have the firmware APPLESOFT card. If you are USing the cassette version of APPLESOFT.• see PART U of ~ appendix for special ins[ructiona and notes on where your APPLESOFT differs fr"m that described in the reSt of this manual.

Inside the APPLE II, across the rear row of eight long. narrow sockets called at the computer from the keyboard end) is 17. Hold the APPLESOF'T card so that its corupu ter; inset t the "fingers" par tion of Blot The fingers w:lll en ee r the .. lot scat firmly. The APPLESOFT card ~ be

n.

of the circuit board, there 1s a "slots." The leftmost one (looking slot I/fJ; the rightmost one is slot s\Olltch is towaro the back of the che card 1.0to til e lef tmos t 510 e , with some friction, and will then placed 10 slot #~. should procrude pare way

4) The through

switch 00 the back of the APPLESOfT card the slot on the back of the APPLE II.

n

5) Replace t.he API'LE's cover: fi'tst slide the front eds" fot.o pre .. " do",,, on [he two rea r corners un til tttey pop into p Lac e ,

place,

then

a

7)

Now turn

on the

APPLE II.

US INC THE FIRMWAREAPPLE:SOFT BOARD 'With the APPLESOFT card's SWitch 1n the downward p08ition, the APPLE 11 will begln operating in Intege~ BASIC when you use reset c t r L B (thia m~nual's way of saying: press the key marked RESEt, then hold d~n the key marked CTRL \OIhile typing B). You will Bee the prompt character >, which indicates Integer BASIC. With the switch in the upward pOSition, rese~ ctrl B will bring APPLESOFT BASIC, instead of Integer BASIC. Ih" prornpt character yo .. "r e in APPL.ESOFt. lIbe" uoing the Disk Operating Sys em, the lnteger BASIC or APPLESOFT, as required. position the 5vitch is set. computer It does up

Note, return while

tn thiB manual, t.he word reset meana [0 press the means to pre.88 the key marked REIllRN, and etrlB holding down the key marked CTRL •

key "",.ked R.ESET, meanS to type B

AN UrPORTANT NOTE: One of the functions of the prompt character, beside .. PROtlPTlng you for input to the ccmput.er , is to identify at a glance ",hiel) language the comput.er is programmed to re"pono to a t that time. For ios t ance ,. up till now you have seen two prompt characters:

J tells

you

*
>

for for

the

Honi tor

p"Cog"Cam(when BASIC (the prompt

you normal

press

RESET) BASIC)

",111 automatically choose not matter in \OIhich

APPLE Integer a third

lnteger

Now We introduce for

character: BASIC. you can easily tell (if you

You can also change from Integer BASIC to II.PPL.ESOFT, or vice "ersa, w1thill!£. operating the switch on the firmware card , To put the computer in to APPL.ESOfT" uae reset ctrl CIlISG return B return put the computer into Integer BASIC, use

AI'PLESOFT floating-point

By

Simply looking Dt this p"Compt character, forget) whicb language the computer 1s in.

aDd to

PART 1: FI.RMWARE APPLESOFT
INSTALLING TilE FIRMWAREAPPLE:SOFT lIOARD The fir_are APPLESOft card simply plugs into a socket inside Care must be exerc rsed , however, so follow t:hese instructions 1) Turn the M'PLE off: very im,portant to prevent damaging the the APPLE tt. e)<.8ctly; compute·r.

rCset ctrl

C~61 return B return

ANfrTHER.LHPORTANTNOTE: Some tOle you may accidenrly hit RESET aod find yourself in the Monitor. as shown by the • prompt character. You may be able to return to APPLESOFT BASIC. with APPLESOI''I and your progrs.m intact, by typing etrl C return

2) Remove the coyer from the APPLE II. This 1S done by pulling up On tha caller at the roar edge (the edge farthest from the keyboard) until the t\OlO corner fasteners pop apart. Do not continue to lift the rear edge, but slide ehe cover backward until it comes free.

106

107

PAIRT 2: CASSETTE TAPE APPLESOFT
APPL"ESOFT II BASIC is provided On cassette tape, at 00 charge" wah each APPLE II. APPLESOFT BASIC loaded from cassette tape occupies "pprol'l:1J1lstely 1l!K by tcsof memory, thus " computer wi th L&K by tes Or mOre meM<lty is reguired to use the ."ssH to. v,ersfoll of API'LESOrr BASIC.

DIFFERENCES

BETW'EEN fIRMWARE APPLESOPT

AND CASSETTE APPLESOn

AFP.I..ESOf'T oncasse t re ta pe (Pa r t N"mber A2TIl~!J4) does no t work exac tly the same lis does the firmware version of APPLESOFT t ha t resides in ROM on II plug-in p'r1nted drcuico:arcl (Pan Nu",bar A261lilll'9l0, M<ls'c of this manual describes the f1rJ!!Ware 'verst<l" of APPL.ESOFT '. 1:he following CO",",eO t s po tn t out how casse cce AI'PLESOFT differs from firmware APPI.ESOFT. Be"ause casse t te APPLESOPT occupies app roximetel), l!ilK of .. emo!.'"')' (and the compu ter uses ano ther 2K), caase t te APPLESOFT c a nne t be U8 cd in APPLE~ wi th lesa than 16K of m,,:mory,. Wi til cas,seue AI'PLESOFT loaded. th .. lowest memory location available to the user 1a appr<lxlmatell' 123!i1~, Fir",wa"" APPI.ESOFT doe" noe reside in 'RAM m.eOl.<lry, so it' "an be us"d ('dchout high-resolution graph.ics) Ln " .... Uer 'sys t"ms.

GEITIHG lise the

STARTFID laTH following

CASSETTE tAPE

Al'l'LESOFT

p~o""dure

l} Sun up t"tege~ ",ith this procedure,

BASIC by typing reset see ycur APfI..E Integer will know you are in lnteg,er BASIC when you displayed on the TV screen, fol10w"d by the
2) and Place the APPLESOFT tape (Pan rewind the tape to the beginning. Ty pe LOAD Press the Number

to 10a.d API'1.ESOFt fro .. your ca,ssetteunit: ctdB. If you are 111<1[ B.ASIC Programming Ha"'lsl. YOlO see the' prompt. character " blinkin,g s quar e "cursor."

,,,,£,, ..

A2TIlG04,)

in

your cassette

~ecorder

IIG!! is not availa.ble in cassette APP'LESOPT. Tile HGRcommand cl.. s "page ar I" of graphics meID.ory (8K to 16K) fo·r high-resolu tiong'Iaphics. S inc .. cassette AE'PLESOFT partly o""upies this pOrtion of memo~y, ,a.tternpt.ing to use
HOR w111 erase AP.FLESO~T, and may eraee your pr<lg,tam, The HGR2 command can be used both in the ROM and 11l the cassette ver s ions of APPLESOr'T ,bu t 19 only avaiLable if your APPLE contains at least 24K of memory. Therefore, in a sySt'em with less than 2,4K of memoly, cassecca APPLESOfl' does not offer higb-resolutIon graphic". The com_nd l'OKE -1631,ll, ~ convertS any f",ll-screen grephlcsonod .. to mixed gr.aplI1cs-plus-t:ext mode, Yhe.. io.sued after HGR2. hcvevar , the fo,," lines 0 f tel< t are taken from M2& 1. of t'ex.t me.m.or:y, Ln the caase r re ver s f.on of Al'PLESOFt ,. API'LESOPT 1tself occupies page 2 of [ex t memory, 9,0 thll t mixed h1gh-resolution g'raphics-plua-tex,t is not available. \lith Integer BASIC, and w1 th Al"PLRSOPI On the U'ttlWore card ,. you Can eat urn to Y<lur p,rogra." after an acc1dentalo't intentional press of the RESET key by ua ins Ctrl C t e turn. To aeco .. p litih the same thing wi til caaa e t t.e APPLgSOF'l'. youl!lust use IlG return (type Iil .• then type G and pres" rhe RETURN key), If you aee using casse tee APPLESOFT, r eae t c I. 1 G return wl11 r"tnstR ee In t~ger SASIC as your programming Language ; this will erase AP'PLESOF1.

J1 4)

recorder's

"play"

lever

to

start

the

cape

playing.

5) Pcess the key marked RETURN on the APPl,S tI keyboa td, When you d9 cilia the blinkIng "U'80r will dtsappeB [. AI ter 5 [0 2!i1 S..conde the APPL.!;; n will beep, to sign"l tho t the 'tape' a i(lfonIlH,U"" has .. ta n,,,d to go 1n to th e computer. After abcut 1-1/2 1ll1nut,e5, there w;:ll be another beep and the prompt chara. 'LeI' " foll""ed by' II CU[SOl' will reappea t. 6) Stop
..

the

tape

recorder

and

cewindthe

eape ,

APPI.ESOIT

is

no'"" in

the

("omput'er

7) Type copyright

RUN and notice

pr,e.68 the key marked RETURN. The Screen for APPLESOFT U Dnd APPLESOFT'a prompt

",111

display

.the

character,

I

Some.time'

Monitor
return typ,lng

may Ilcciden tally bLt the RESET key and find yoYr.ee,lf in the 8$ shovn by the prompt choracte'[" You may be able to [0 APPLESOFT, wlth your pc'ogram and APPLESOF,[ 1t8eH still inrllc,t. by you

program,

In short, APPLESOTT from
w"111 tranof.er

If this tape.

do", .. n"t"'ork,

you

...tl1

hllveto

re-load

'C'HI6"[[e

eVer"ywheTe th19 manual r,esetcnl C re curn c...ssene API'LSSOFT use ra should ,e.se t !iIG retu co, lostead. "ay"
to use you

(lays u....

to use

Typing errl
In t"ger:

C or ctrl B EroID the Hon1t<l[ program BASIC; thi s will erase APPLESO:F1'.

you

to APPLE

\./here i:he manual
resetyOLl

ctrlB

te.tur"n

can

do che

saee , but

iii 11 'then

have

to

reload

APPLBSOPT {rom tape,
cbar clear io""" the the the

In the

this key

pres!! the

irulnu a 1 , reset means to p eeas )(,ey ·.... rke.d RETURN" andettl mil.,,",d CTRL •

the key marked RESET, rerurnmoans B means to type II wh11e holdin.g

tQ

down

Tn cassette AI'PLESOFT, use CAJ..L 11246 (inBtead DE CALI. 6245~;) to nGil 2 screen to black, Use CALL L12 S0 (ins tead of CALt. 624'54) to UCR2 screen to the HCOL.OR last IIPLOT ted.. If execu ted beto re y"u lICR. command the Hut 2 [ime, these CALle may erase APPLESOI'T.

108

109

Appendi1x B: Program Editing
Host ordinary humans make mistakes occasionally •.•espec1ally when writing computer p rcg rsma, To facilit.Bte cO.rre<:ting these "oversights" aPPLE I\O.B incorporated a unique set of editing feat~es into APrLESOFT SASlC. USe of tDem you nIl first functions of four special keys on escape key, marked ESC, the repeat dght-arrow keys, which are marked
TO make

REP'I

Ille REPT key is used with another character key on the keyboard. It causes n character to be repe"t:ed as leng as both tbe character's key and the REfT key ere held down.
No,", you·I.e ready to use these edir:Lng functions tD allve U.rne when making c.hanges 01:" COl:'rec.t.ions to your program. Here are a few examples of how to

need to familiarize yourself with eh the APPLE II keyboard. They are the key, marked REPr, and the le£t- and with a left arrow and a right arrow.

use cham.

Example ESC The eSCape key ( ESC ) is the leftmost key in the second row from the top. It 1s ALWAYS used with another key (such as A, 8, C or D keys) in this way: push and relea.se "ESC, and then push and release A, for Lns tance ...• alternat.ely.
This

1 --

Fixing

Tvpos a program by typing 1t. in, and when you RUN it, the ERR and stDPS, presenting you with the. I pt:ompt and

Suppose you "v« entered computer prints SYNTAX the flashing cursor.

Ente'. the following program and RUN 1t , Note that '"PRIMI'" and ·'PREGRAM" are mis-spelled On purpose. Below 1" app<Ol<imlitely how it will leok. on your TV display: ".

ope.ration or sequence of the ESC key and then another key 1s written "escape A·'. There are four escape functions used for "diting:
escape
esc.ape A

I HI

PRIliT

'"TRIS IS A PReGRAH"
HI

8 escape C e:"c.apeD

to rne right [0 [he left moves turso\" down move.s cursor up
moves cursor moves cursor

}2!1 GOTO

IRUN
?SYNTAX

Using the escape key and the desired key, the cursor may be moved to sny location on the: screen without affecting anything that is already displayed tbere, and without affecting anything in memory.

)I

ERR IN

IIJ

Now type the word LIST
ILlS!

and press

return:

RIGHT-ARROW

KEY

20

III PRIMi"TlIlS GOTO 111

IS A PREGRAM"

The right-arrow key moves the cursor to the right. It is the most time-saving key On the keyboard because it not only moves the cursor, but IT COPIES ALL CHARACTERS AN1l SYMBOLS rr "HOlIES ACROSS" tNTO APPLE: tI'S MEMORY, JUST AS IF YOU HAD TYPED THEM IN FROM TIlE KEYBOARD YOURSELF. The TV dispLay is not changed when you use the right-arrow key.

)I
To move the cuCllor up to the beginning of line Iii. type e.. cape D three times .. nd chen es cape B. Note: it is 1mportant to use escsp., B to p.1ace the cursor ov"r th .. very fint digit in the line number. The TV screen .,111
nOW

look like this:

LeFT-ARROW

KEY

J !.lSI 'I PRIMT'"THIS
211 GaIa 111

The left-acrow key moves the cursor to the left. Each I. ~e the cur90~ moves to the laft, ONE CIlARACTER IS ERASED FROM TH.E PROORAM l.INE WKICH YOU ARE CIJ'RRENTLY TYPING, regardless of wnat the cu eae r is moving Over. The TV display 1s not chonged "hen you "Se the left-arrow key. Usually tne 1aft-arrow key canno e be used to move the cursor into the leftmost column: use escape B to do this.

IS A PRECRAH"

110

111

Now press

tl'l" righ e-a rIOW key f> Um.es to '".o"e the CU tao r on to the leaer H in "PR,[HTn• Reme.mber ,. liS the rigtle-arro,. key moves the cur so c cvec a cha rae rer on en" se reen , t 1'111 e ehaeac ter is copi.ed in to API'LE' s memory jus r as i.E "you had typed I t t n fro", t ne keyboard. The TV d t sp I ay 10111 nl>'" look I1ke this; ILlST

&"""21."

2 .,-

Insetting

Tex.t

lnto

an Existing.

1..1ne

In t he previous ex.ample., auppoae you had wan ted to inse r t a TAB(lll) command s.ct"" the PRINT in lin" I!l'. Here's h"w you. could do H. First LIST the li"e to be ehanged:

u.tsr
1 S A PR EGRAHn

tr;1 IS A I'ROGRAM"

!Ii PR rlli "THIS 210l COlO HJ

III

PRINT "THIS

II
Now type
the dgh the leuer N to correc c the spell:log

e-a [(0'" key and t he repea t key) over The TV sc teen will now look like th; s:
lUST HI PRlln"TH15 IS A PRI):;RAM"

of "PlUM,!". then copy ("91n8. to th e lett·"r E. 1n "PREGRIIM".

Type

eharuc ·tero!

the cur'soz 1s 00 the vcry first tllen oseth.e r igh t -ar row and <c peat keys [0 copy over to t.h.e first quotation mark. (Re""",ber, a charlie ter .is "ot copied into memory until you use [he right-ouow key to move the cursor from eha.[ ebarac t er on to the next , ) Your IV display Should nov look Uke thts: ILXST I~ 1~ .-rillS IS A PROGRAM"

escape

D's

and an escape .B until the line to be changed;

211 G(}tO HI

PRINT

If you ~yped the right-ana,", key too many times by holdIng key [00 long, UBe the. l"f [-arto" ke)l to backs pace ba.ek. to No"', type tho 1ene~ 0 to cor ree t "l?REGIIAM" and copy ".inS It. .,y to the end of Ldne HI. Finally, "to.te the n"." line in. pr·""sing the RETURN key. T1'pe LtST ILLS! to see your corrected

dow" the Topcnt the Lee t,n E.
the r;i'sht-arro"" progta .. me",ory by

Now typea.nothe[
the cur renr line ILlS'!

escape D· to !nove the cur se c to and the display will look like;

the

empty

Ilne

just

above

Iii

program'

I!I

PR I ~I

"nils

IS AI'ROGRAM"

III 211

I

PRINT "tillS GOTO IIJ

IS A .PROGRAM"

Type

the

characters

TV display lUST I~

should
TAJl

to be inserted wh1"". nOw look Uke this;

1n this

case,

(Ire

tAe· (U·);.

Your

JI
No..

RUN

the

p n>gu.m

(usc

c. t r I C to ".tOP the

program);

(HI);I
IS A PROGRAM"

HI

PIUIl!'

"TillS

THIS IS A PROCRAM nus IS A PROGRAM THIS IS A PROGRAM

IRUU

THIS IS
THIS TillS THIS

THIS

A IS A IS A IS A IS A

PROGRAM PROGRAM PROGRAM PROGRAM

Type Uke

On escape thill'

C to

mcve the cursor

down one line

so

thu

th .. di "play

looks

)L.IST
lf1'

II!

PROCRIIM

PRltfr

TAB (Hll; "THIS ISlA

PROGRAM"

BREAK IN I~

II

1t2

113

1'10'"backspace back to ehe firSt quotation marl< using escape B (using left-an-ow key here would delete [he characters you have just typed). IV display will nOW look 11ke this: ILlST HI

I,..

·rh.·

Appendix C: Error Message
A.fter II.n er ro r OCCurS, BASIC rerurns to command level a a indicated by t.he 1 prompt character and a flashing cursor. Va rLableval.ues lind the program te.xt re .... f.n intact. but the progra .. can not be con t.Lnued lind all GOSUI! and FOR loop counters sre set to To avoid th1. interruption i<I a running program, the ONERR GOTD statement can be used, in conjunction with an error-handling routine.

111 Plum

TA1I(l!l): .THIS 15 A PROGRAM"

e.

until

From h~re, copy tbe rest of the line using the display looks like this:
]LIST 111 TAB(ll,l): "IBIS IS

tbe

right-arrow

aod

repeat kayo

When an e.r ro r occurs printed.

in an immediate-execution

statement,

no line

number

is

Fo~mat of error
A PROGRMI".

messages: Statement ?XX ERROR

111 PRINT

Immediate-execution
Deferred-execution

Statement

1XX ERROR IN YY

Depress ILIST

the

RETlIRN key and type L,I5T

to

get

the

followiog:

I II! 21!

In bo tn of the above examples, "lOl" is the name of the apec1 fic er IO r. "YY" 1s the line number of the deferred-execution statement whe~" th a er ro r occur red , Er.t'ors in a delerred-e>l""urton statement are not detected until

PRiNT

TAB(

I!lJ;''THIS

IS

A l'R

that statement
The following

1s e.xecuted.
are the possible en:or codes and their meanings.

Where you wish to avoid copying extra spaces wh1ch the LIST format 1ntroduc:es 1nto the middle of lines (such as those between the R and the 0 of PROGRAM,1n the example above), USe ~scape A. Escape A mOves the cursor to he right Without copying characters. This can be especially useful when copying PRINT, INPUI and REM statements, where APPUlSOFT doe" not igno~e extra "paces. copy and edit te)<t that is

coto HI

OGR.AM"

CAN'T

CONTINUE to continue a program wh~n none existed, or afcer an error occurred, a liue was deleted from or added to a program.

Attempt or after

DIVISION
DIviding

BY ZERO
by zero is an error.

Remeoiber, displayed

using the escape k"ys, one ""'y 8ny~here on the TV display.

II..LEGALDIRECT
You cannot use an INPUT, DEF FH, GET or DATA statement i.mmed1ate-ex~cution comlll8nd.
8S

an

lL~EGAL QUANTlTY
The parameter passed to a math or string QUANTITY ".rors can occur due to: B) D negative array SUBSCRIPT (e.g., b) uBing LOG with .. negari.ve or ze ro c) using SQR with II oeg4 ei.ve ,agu""", d) A-g with A negative and B not an ~) use of HIDS, LEFTS, RIGHTS. WAIT, ON .•. Goro, or any of the graphics improper argument. function
Waa

out

of

range.

ILLEGA.L

LET A(-l)-P) argument
t

integer PEEK, POKE, TAB, SPC,
Eunction.s with an

114

115

NE;ITWITKOlIT

FOR not correspond or a "",m"les8 to the variable to II FOil NEXT did cor ceapond eo

BAP SlJllSCRIPT An att.e:mpt: dim.eusiona dimensions ... has been wa's made t.o :refer~nc,fi' 8.1l a):ray el~!1Ient_ TJhich is: 'o-u'tside the of the array. Th.Ls e r r o r can oc cur if t ha ",,",ong number of are used in an ar rayrefe·rl!nce; for ins cance , LET A (1. 1. I) -Z .,hen dimensioned using DLM A(2,2).

The variable in a I!IEXJ: statement did st,atem",nt which was ,still in effeet, any FOR which was s tin in e flee e ,

OUT OF DAtA
A READ s tat!!lnen r waseK",cuced bu e a 11 of the DAtA s ta tl!merl'ts 1n the had already been lead. the program crf.ed to read too much data Dr insuJf1cient data was 1ncluded in the program. ptog ram SYNTAX ERROR Hissio.g pa renehes Ls in ponctuat1on~ et~~ an e:Kp~ess:lon. illegal chaeac cer in a line, incorrect

OUT OF MntOR't An,y of the folloying can cauae this e rro r e p rog ram v,adables; FOR loops nested mor e than Hi! lev"ls deap than 24 levels deep; too complicated an e>tpre"sion; thao 36 levels deep; attempt to set LOMEM.; to" high; lower thanpn!s(mt valLIe; attempt to Set IIlMEM: too 'too Lar ge ; e oo many ; COSUB "a nes eed .. orB parentheses ne"l:ed ~Qr attempt to Bet LOMEM: 10""

T'tPE MISI1ATCtI the: left~hand si..deof an B9s1gnment statement was 8 numeric variable and th'e rtgb t-hand side "-'laS a string I or v i.ee: ve.rsa,~ 0,[' a func t,ion which axpec ted a st~riflg .a rgUlluun; was given lEInU):'rI:eri<:: one OT vice: ve.rSa ..

UND EF 'D FORMUI..A

STATEMI!.tn' IrUlde to GOTO"

roo

COMPL£X statements of the torm IF "X:X" THEN w e ,,!executed.

Hor .. than

Ao attempt was does net, exist.

casus

or

'TtI,Ellto

a ara tern.ent

line

number

which

1:"0

OVERFLOW The .esul t of a cal culaUon !.';IS too large to be l'cpresen ted 11'1liASIe" 9 n,umbe'[':fonca c ~ 1f an Lmde"flOlrl occ.urs" :ze.rO is gi van as t.he t'"esul t and ",,,ecution continues without any er ror messag" being pr1'oted.

UNDEP'O FUNCTlDN Reference
"!IS

made to a use~-def Lned Euct,ion which

had' never

been defined.

REDl!1'D

ARRAY

Aft"r an array ",as, dlme"sioned, another d1,,"eo'9100 "["temeot for the same or ray en"ountered. This er ro r oit'en oc cur s if an array has been given the default dJmensiDn 11;1because a, Ststement lik.e ... (1 )"3 ia followed lllter In the program by a D111II(11'111). This error message een prove useful 'if you wish ~o discover on what program I1ne a eertntn arrey VQS dimensioned: Just insert a dimension 9tatem(!'l't for that array in the fitst line. RUN the progra.m, lind APPLESOft will t,ell you where the original dimenSion statement 1s.

"'.8

RETU!!.N YITt10ut

cosue
"'ss encounce ced ",1 [hoy[. a co r r e.sponddrrg COSUB s t.at.emenc

A RETURII statement being executed.

STR INC

tOO LONG of the long. ecncacenat.Ion ope ..."[or to c eeace " 9tting

At ['(lmp't was "'-!Ide by use mor" than 255 chnr"ctllrB

116

117

Appendix D: Space Savers SPACE HINTS
In order to make your program fit Into less memory space, the follow1ng
hints may be useful. However, the first t",ospace-savers should be coosidered oo.ly when faced with serious space limitations. Serious programmers often keep two versioos of their programs: one. expanded lind heavily documen ted (with REt!' l , the other "crunched" to use the minimum s m"mory space. Use mu~tiple statements per line. Th,ne is a small amount of overhead associated with each line in the program. T';oo these £1v bY~"N of contain the lIne num.ber of the, line 'in b 1nI11:)" Th is means t h a t no rrul ne~ how many digitS yOti have in your line number (minimum line number is II. maximum is 65529), it: takes che same numbe.r of bytes (two). Putting as mony statements as possible on each line will cut down on the number of byt:es used by you~ program. (A Single line can include up to 239 characters.)
1)

n Use GOSOl!'s to execute sections ldentical actions.
8)

of program
for

statements

that perform

Use the ~e[o elements of marrices;

instance,

A{g), B(g,Xj.
"CAT" Ls not

9) lIbe" A$-"CAT" Ls reassigned to AS-nDOC" the old string erased from memory. USing a statement of the form

periodically within your progra.m will cause APPLESOFT .trings from the top of memory.

X - FRE(IJ)

to

"house clean" old

(5 bytes)

STORAGE ALLOCATION INFORMATION
Simple (non-array) real. integer, o r scctng variables }i'ke V, v:t, or V$ use 7 bytes. Real vsriables use 2 bytes for the vadable name and 5 bytes for the value (1 exponent. 4 qantissa). Integer variables use 2 bytes for the variable name. two bytes for the value, and have ~·s in the remaining three bytes. String variables use 2 bytes for the variable na.me, 1 byte for the length of the srr f ng , 2 bytes f.or a point"r to the: location of the s t.rd.ngin m~ory, and have ~'5 in the remaining 2 bytes. Sce page 131 for map. Real array variables use a minimum of 12 bytes: tVa bytes for the variable n~t two fo~ the size of the array~ one for the number of dimensions. t~o for the. sIze of "ad dimension, and H"e bytes Eo·. each array e1", ent. .. Int ege r array variables uaa only 2 bytes for each arrllY element. String arrsy va.r1ables use 3 bytes Ear each s'tray element: one for length, two for a pointer. See page 137 for map. StIing variables, whether sit:lpleor ar ray , use one byte of memory for each Ln the s t [tng. Thl! suing" themsal,,!!s IIrl! I ecaeed til order of cx:curence In the progts ... beginning "t IIIUEM:.
char ac rer

lIote: comhining many st.stements on one line makes "diting Bud other CI10l\8"6 very difficult. It also makes a program very difficult to read and understand. not only foc others but also for you when you recurn to the program later on.
Z) Delete all REM statements. Each R.t:M statement uses at least one byte plus the number of bytes in the common text. For instance, the statem nt 13G REM THIS IS A COMMENT uses up 24 bytes of memory. 1n the statement 14P X-X+Y: REM UPDATE SUM the REM usell 12 bytes of memory including the colon before the REM.

Note: like mul [tple-line programs, a program without deta'Ueci REM seau," ntu is very difficult to read and und rstand, not only for n[he.s but aLae for you when you recurn to the program later on.
3) Use integer instead oE r".. anaya .. l he.ever possible AlLocation Information, later in this appendix).

When a new funcHon is de£ined by a the poin te.r to the deli n1 t10n.

D&F

statement,

(> bytes are used

to store

(s"e Storage

4) Use variables instead of constants. Suppose you use the conStant 3.14l59 ten times in your program. If you insert a statement in the program, and use P inste,ad of J. 14159 each time it is needed, you will save 4(1 bytes. ThLs 101111also result in a speed improvement. 5) A program lIe.ed not end With an EIID; so, an END statement at che end
U

Re$erved worda Stich as FOR. GOTe or NOT, and tho names of the intrinsic functions such as COS, !NT and StR$ take up only one byte of program storage. All 0 her chara~ter8 in programs use one byte of program storage
eacb .

til P..).14159

When a progrsmis being executed. stack as follov9: 0
I)

space is dynamically

allocated

on the

Bach active FOR ... NExr Each sctive GOSUB

loop uaea 16 bytes.

programlMY

be deleted.

2)

[one that has not RETlIRNed yet) uses 6 bytes.

6) Re-use the same variables. If you have a variable T which is used to hold a t!!mpora..-), result in on" part of the ptogulD and you need a emporary variable later in your program, use it again. Or. if you are ask Lng rh computer's user to give a YE:S or NO anSwer to two different quaat Lens at t.,o <I if ferent times during the execuc t cn of the program, uoe the sa~e temporary variable A$ to store the reply.

3) t:ach parenthesiS encountered in an expression uses ~ bytes and ench temporary result calculated in 'In expression uses 12 bytes.

118

119

Appendix E: Speeding Up Your Program,
The hints b'_lo .. should i.mprove the ·""ecueion time of your BASIC programs. Note eha t. same of e ne,$e l1int:s a. r e the same as tltos~ used to dec.re:asf! t,he ..emory space used by yeur programs. 'Ihis ... eaus that in !!!IIny cases you can inc.rease t.he speed of }I,mI' p'rognl!JlSllt the same eime you impro"" the efUciency of their memory use. I) TillS IS

AppendixF:
dcei<ll4l toke" 128

iDee.imal Tokens For .Keywords
decimal t:o;u~n decimal to\<:,m

keyword

k.y,",otd

k"y,",ord

veri.ables
i.uflOll'tin,g va l.ue ofa FOR••• NEXT

ina read

IMPORTANT SPEBD H11<1 B,Y A FACTOR OF HiI:ulle 1 t cakes mo'(e time to convert, a couse,sn t to point (real number) represent,ation tnan it dces to fecd, the simple or array variable. This La especially illlponan twi tntn loops 'n" other code that is .'lU!cuted repeatedly.

PROBABI.Y

TRE MOST

129 IJ0

END

of COns e an ta.

IJI,

133

131 132

DAIA DEL
INPUT DIH READ GR TEXT

FOR NEXT

1610 165 166 167 168 1,,9
17 !I

LOMEM:
OIlERR RESIJHE RECALL STORE SPEEDLET GOIO RUN IF RESTORE 6 GOSUS

20!! 201 2i12 21J3 2i14 2115

+

*
AND OR

2) Variables "'111en program are allocated sta,b~'we:nt such as 5 ~. ~, R-

are encountered at the stalt

first of the

during
variable

the execution o.f a BASIC t".ble. Tllis 1["«,,n. th!!t

136
11

135
138

137

A:C-A

139 14i'!
141

INI CALL

PR,

172
173
1710

17l

206
2i17 2i18
2!19

>
c SGN INT ASS

PL.OI
HLlN IfLIN

175 176
U7 LtS

RETURN
REM STOP ON \JUT LOAD SAVE DEF POKE PRINT CONT LIST

"tIl p Lac .e A Ilrat, B ... cond , and C third in the variable table (,,9.suIlIlng ~ine 5 1s the first sra tem.ent In. the progrl).!n). Lacer in che program, when BASIC find" a reference' to thl! varlable A, it "Ul lIell'rch .ol1l'y one "nny in che variable table to .find A, cwo enCrie" to find B .and three entr ies to f:inll C, .'te.

~"."ut"d

142: 143 1&4 165

146 147
148

HCal HCR

179 ISIJ 181
182 IS3

21~ 2L5 217

2!~ 211 212 213

us!!.
FRE SCRN(

216

POL
POS SQ!!. RNa

3) U"e NEXT s ca te!Den es "i tllo<l t the than NBXT r because no check i.made

NEXT'ill the
statement.

""1m,., Illi the ""r!able

in

inde1<' var iable. to see if the the moflt recent

NE1rI ill SOllle","a t fa9t",!: var Lab Ie spec Uied inthl' stiH-Ilctive FOa

lSI
152

149 15!J

lWRAW IIT'AB
HOME ROT .. SCALE .. SJrulAD TRACEl IWTRA.CE N.ORMAL

DRAW

IICOUlR" HPLOT

ta4
lEIS
L86

WI
221 223

219

218

LOG
EXP COS

222
224 Z25 226 227 228
229

4) During progrs,," execution, wilen ,Al'PLESOFI encounters" DeW Ii fie "derence such as "GOIO I.!"~!!" it scans the ent1re user prngrem sCRrting at tll'e lo"es~ line untH it finds the refereoced 11ne number (U!l0, 11"\thia el<:lI.mp1,,). Iher.efafe, t'Teque!lt.ly-rcferenceli l1nell"llould be p Lac ed ae early In the program as pass:lb 1,,,.

153
154

15S
156
157

187 188 189 191J 191 192
193

SIN

TAN

CLEAR
GET

NEW
TABC TO F'N SPC( AT

IITN PEEK LEN
STR~

VAL

158
159 161

INVi>RSE
Fr..A.SH COLORB PDP VTAB IflMEM:

i6!1

194 195 r96
197

23a
B.I

MC CHR$
LEFT$ RIGHT$

TlIEN

162 163

198
199

NOt STEP

23;'

233

232

1110$

120

121

Appendix

G: Reserved Words In APPLESOFT
The ampersand ( & ) is intended for the computer'$ internal U$e only; ir is nor a prop e r APPLESOPl: command. This symbol, when ax ..ut ed as an c instruction, C,8useaan unconditional jump to Loce t i on $3F5. Use roset. c t rI
C return
tOE;eCOVe.['.

AllS

AND CHR$

Ase
CLEAR
DEL

AT

ATN CONT cos

CALL
DATA

~

DEY
EXP
FH

DIM

DRAW

K!'l.OTis " reserved
cOau::iN!nd~

word that does net eor rnspond

to a current

APPLBSOFT

Eml
FLASH

FOR GOTO HCR2
ltlPUT

FRE
GR HIMEM:

Some reserved words are COLOR, HLIN INVERSE
LOAD HOME

recognized

by APPLESOFT

only in certain contexts.

GET HCOLORs

GaSUl!

HCR

I!PLOT

ATAB

IF
LEFT$ !uD~
NEil

INT LIST

LEN

LET

toe

HCOLOR, SCALE, S PE:ED, and ROT parse as reserved words only if the next non-space character is the replacement Sign, -. This is of little benefit in the case of COLOR and HeOLOR, as the included reserved word OR prevents their use in variable names any"ay. S!'C and TA1i parse 89 reserved ,",ordsonly if the next non-space character is a left parenthesis, ( . must have in c 0100
IJord.
( , )

LOMEli: SCRH,

NORMAL

Nor

NOTRACE
Hl:MEH:

ON
PDL

ONERR PEEK RECALL
RND

OR
PLOT pop

to be parsed as a reserved
) 1f it is to be parsed

ros
RETURt4 SIN STORE IRACE

PRINT RIGHT$

PR8

LOHEH: ATN

REM ROt .. SCRIl( SQR lEX!

RESTORE RUN SCN StEP
THEN

RESUUE

a1 so .requires a colon a reserved "oed.

as

SAVE

SCALESUEDTAN

Sli.LOAD
STOP

SPC( STR$

1a parsed as reserved wonl only if there is no space beewe"n the T and the N. If a space occurs between the T Bnd the N, the reserved word AT is parsed. instead of ATtI. Ls parsed as a reserved ~ard unless preceded by an A Bnd there 1s a space between the T Bnd the O. If a space occurs between the T and the 0, the reserved word AT ,is parsed instead of TO. pacentheses FOR A FOR A FOil. A FOR A • • • • csn be used to get around LOFT OR CAT TO WI' TO ItC AT TO (l.OFT) OR (CAT) (LOFT) OR (G AT 15 1S TO 15 ) TO 15 reserved words:

TAB ( (lSR

TO

TO

VAL WAIT
lfPLOT

VLIN

V!AB

Sometimes
XD.I!.AW

APPLESOFT "tokenlzes" these ~eserved words' each WQJ:"dtakes up only one byte of progro.m storage. All other characters In program storage use up olle byte of program storage naeh , See Appendix F for reaerved-vc rd tokens.

1~0 100 101J but LISTs as lQQ LISla
6S

122

123

Appendix

H: Converting

BASIC Prog.rams to APPLESOFT
3) Some BASICs allow "mul dple assignment" statements of the form

Thougn1ml'lementations of BASlC on different computers lire in many ways similar, there are some incompatibilities .. i.eh you should "atch .tor if yo" h are planning to convert l!ASIC programs to APPLESOFT. Array (matrix) subscripts. Some BASICs use" l " and "I" to denote <leroy subscripts. APPLESOFT uses "C" and ")".
J)

'this statement would .set both the variables Band

C to zero.

2) Suing". A number of BASICs force you to dimension (declare) the leng h of strings before you use them. You should remove all dimension statemcnL8 of tbis type from the program. In sOme of these BASICs. a declaration o. the form DIM AS(I,J) declares II string array of J elements each of which hM a lengrh 1. Convert 0111 statements of this cype to equivalent ones in APPLESOFT: DIM AS(J).
APPLE$OFT uae s "+11

In APPLESOFT BASIC this has an entirely different effect. All the -'s to the right of the first one would be interpreted as logical comparison nperators. This would set tbe variable B to -1 if C equaled 1,1. If C did not equal 1,1, B would be set to 0. The easiest "ay to convert statements like this ODe 1s to rewrite them as follows:
B-C

fcu:, st'rtng

ccnce.renat

Lon ,

not II,"

cr

"&Ii. A)

So.. BASICs "
Change

u.se "]" instead of ";" to delimit mult.iple statementS per

APPLESOFT uses LEFT$, II.1CIIT$ and MID$ to take Bub.tr.ings of st.tings. Othel" BASICs use ASCI) to acee •• the lth character of the string AS, and A$(l,J) to take a Gubst~lng of A$ frem character position I to character position J. Convert as follows:

line,.

each

upt

to

It,. II

'in i::he' p'rcgram.

NEW
AHI) AS(l,J) IUD$(A$,l,l) 111D$(AS.I, J-l+L)

5) Programs which USe the KAT functions available in some BASICs will have" to be rewritten using FOR ••• NEXT loops to perform the appropriate operstions.

This assumes that the reference to 8 substring of AS Is In an expression or i. on the right side of an assignment. If the reference to A~ Is on the left-hand 8ide of an aSSignment, and :>:$ Is [he strIng expreSSion uSed to replsce characters in AS, convert ss follows:

AS(I )-X$

A$-LE"FT${A$,l-I}+X$-IMIDHAS,l+l}

AS(I,J)-X$

A$-LEFT$(A$,I-I)+X$+MIO$(AS,J+l)

124

125

Appendix
MEMORY RANGE 0. LFF

I: .Memory Map
DESC1UP'rlON

DIAGRAM OF APPLESOFT PROGRAM MEMORY MAP
caSsette: E1rmw"re

version

po1nte.r Disk Operating
Sys.[,em used)

verston

Program
Keyboard

1.10 rk

space;

no t ava.LLab.l e co user.

(1£ d:lsk

is being

characne r buffer. !!lachine

Alia Hable to user fo r short Language 'Program". 4!J!J.1FF

Screen Al'PLESOFT

display

IIrell

for

page
t

1 text

0"1' color

graphiC$.

$73$74 (HUlEtt: J IBMEI'!: 1s aur,omattcally se t [0 the maximum RAM me.mory Jecae t en 1n the system, u!llest;! set by the user. STR INGS

In caase tte

t,ape ver sion

the

IIASIC

1ntepnter.

$6F - SIC!
FREE SPliCE ohe high-resolution

APPLE;SOFT (Part number A2.B01111!9X) I.nscalled, uaer progr ..m and variable space, "here lOQ( 1s mwc1m"., RAM marnot'}' to be ".ed by AP[>!.8S0FT. This lsd ther to't.at 5yat'e.ro ,RAM memQry, 01:" leG,S if t:he u,aet' is. reserv.ing I'll rt of h1gh Ill.emory fo ~ ....chine 1.anguage routines or lligh-resolut1on GC"l'een buffers. If firmwne

1ncluding grllph!",'
( ...1 th

8cr",," buffers

211!1I1. 3FFf

Fil'1nWare graphics

APPLESOFT only: high-re.solution display page 1.

Cassette to pe ArPLESOn: n; user program lind var ill bleB "'here )()[X is ms><imum Hable RAMmemory to be ava used by ./!.PI"I.ESOfT. This is e!ther to tal system RAMmemory. or less H the user 1s
reserving Language.
pllrt of routines

cas se t r e APPLES OFT. only. page 2 is available). NOTE: sainll space may -fill "'itn old data and ro!! over the high-~esolu[ton screenS or mach!"e progI,ams. 10 initiate house-deaRing and and avoid th1s problem, Insert :<"FRIH~) in your program.

hlghmem.ory for machine or page 2 high-resolution d 1splaj' page 2.

graphics.

S6D - ~6E
tHflll?RIC AIm STRUIG-POINTBI! ARRAYS (see pag" 137) S6!! S6C

4(1t.l(l.SFFF

High-resolution

gr'aph1clI

CillI!I.CFFI' D!I!JII.DFI'F D(!!J!I.F7P!' e!lrJ!J.F7FI'
1'811(1.HFf

II.lIrd"'are I/O Addnsses. Future ROM e xpana Lcn ,

APPI.ESOFT APPLE

n

f1rmvare BASIC.

version,

wich .... lect

SIMPI.EVAAIABLES
$69

(see pas" 137)

9,,1 cch "ON" (up). Integer

- $6A (LOMEI'!:)

APPLE Syste .. Monitor.

SAP - S.n\!
PROGRIIM $3~1I1

$67 - $68

$2FPF /'.PPLESOFr

F7F.F

126 127

Appendix

J: PEEKs,POKEs, and CALls
I~ PO,,'!': 32, L
that yeu can
USe

lIere are a few of the special features of APPLESO:FT meanBof PEEK, POKE, or CALL commands. Notice that the effects of other commands in APPLESOFT. Simple switching

by

some of them duplicae

S [8 left margin of TV display Ihrough 39, ...here 0 :Is leftmost

the cursor attempts
the

specified by L, in the range from ~ position. This change is not effecced until to "return" to the left margin. to value

involving

actions are usually address dependent: any command that address will have the same effect: on the switch. Thus,

example may be POKE -L6304, 11 but you w1l1 set the same effect by POKEing that address with any number irall1 11 through 255, or by PEEKing t:hat address: X ~ PEEK(-1630ql This does not apply to commands 1n which you must POKE the required address with a specific value which sets s margin or moves the cursor to a specifiC place.

The w1dth of the window :Is !!2£. changed by this command: this means that ehe right marg:!n 101111be moved by the same amount you move the left lIl8rgin. To preserve your program and APPLESOF1", first reduce the .. indow ...idth appropriately; then change the left margin .---

20 POKE 33, Sets ehe

W TV display to the value

specified

width (number of characters per line) of by II, in the range from 1 t h r ough 1.[6.

SmlNG

THE TEXTWINDOW
Do not set II t.o z"ro: POKE 33,

The fi<st four POKE commands. with example line numbers 10. 2~, 3~, and 4~. are used to ser the 5i2" of the "window" in which text is shown and scrOlled on your IV Screen. Th~se set, respectively, the left margin, line width,
top margin and bottom margin of the wiodow. Setting the r"xt Window does not move the cursor into th .. VIAB commund ignores the tm,[ appears normally, while rexr l1ne. HTA8 can also move the enough to print one character
A

0

bombs APPLESOFT.

not clear the remainder of the screen, and does text window (USI! HOME, or IlTAIl and VIAe). Th.. w.lndow en[l.rely: text printed above the window printed belOW the windo,", appears all on ODe cursor outside the wLndow. bu only long there. but a change "return" to in the the. leEt

if W is less than 33, the PRtNT ~ommand's cbacac t.e ra ou tsid .. the window.
JQ POlO: 34, T

third

tab-field

may

print

chan!;e tn line width goe .. into effect immediately, left marg1.n ia not detected unti I the cur sor tries ",argin.

to

Sets top margin of TV display to va.Iue spec! Bed by T, in the rang from" through 23 where" !s the top line on the set ..n. e ,\ POKE 34,1, will not allow text to be printed in the first four lines of the screen. Do no 8et the top margin of the window (Tl 10w"r than the bottom matgin (8, below).

~B POKE 35,
Text displayed on the TV Screen is merely a special map of a particular portion of APPLE's memory (text page I). The TV screen always "looks at" this sam" portion of ·memory for its text, and see", what the APPLE has ""'ritt"n" there. lIhen you change thl! [eKe window, you are telling the APPLE where in ",e",ory to ""'rite" its text. This "'orks fine, BS 10l\g as you specify a portion of memory thar ts ~ the usual cel<t a r ea . But 1f you set he left margin., 88Y, to 255 (the maximum should be 40. since the sc reeu is 411 print-positions wide), ),ou are telling the APPLE to "write" text far beyond the usual ",e",oryarea reserved for text. This memory is not shown on the screen, and l!I8y conrain parts of your program or evell infot'marion necessary to APPLESOFT itself, To keep YOllr program and APPI..ESOfT safe, just rafrain from settiog the text "indo," beyond the confines of the 41l-chllracter by 24-line screen.

B

~

Sets bottom margin o[ TV display to value specified by 8, In the range from " through 24 where 24 is the bottom line On the SCreen. 00 not set the bottom margin of the windo", (6) highe< than the top margin (T, above).

OTHER COMMANDS AFFECTING TEXT, THE TEXTWINDOW AND THE KEYBOARD . ,
~5 CALL -936
Cl"~H" all characters inside the t.xt window, and mOves the cu r so r ,to the \l!nd~' .. top leEtmost printing position. This 1s the same as esc @ return (EBcnpe @1 and the cO",m;Qlld HOME.

128

129

511 CALL -958
Clears all
characters inside of cext window from current cursor pOBiUon Co bottom margin. Characters above che cursor, and charac eers to the left of the curaoz 10 its prl..nting, line: will not be a:ffected. Thls is the same OJI esc F (Escape, F).

If the cursor is above the text \lindow, clears from the cursor to the right. lef t and bo t tom ma rai na as if the top margi 0 ware above the cursor. It ill not usually des t rab l.. to use this eonaoand if the cursor is below the bottom margin of the te"xC window: usually the bottom line of the text window 1s cleared, along vith one line of text-Wlndow Width at the cursor position. 611 CALL

position relative to the text window's left-hand margin, as set by Thus, 1£ the left margin was set by POKE 32,5 then the leftmost character in the ... tndow :ia lit the 6th printing-position from the left eds", of the sc reen aodif PEEK (36) retul:ned a value of 5 then the cursor was at the !lth printing-post tioll from the left edge of the screan and at the 6th printing poa1 tion from the left margin of the te,xt window. (It sounds confuslng at first, because the leftmost position 1s posl~on zero, not t.) ,[hiS 1s identical to tile POS (X) function. (See next eKa"'ple.)

cursor's

POKE J2,L.

1211 POKE 36,C8 Moves the cu.rso>:to a position that is CH+I printing-positions from the left ~rgin of the teKt ",indo,",. (EKample: POKE 36,11 will cause next character to be printed at the left margin of the window.) If the left margin of the windo,", was set at 6 (POKE 32,6) and you wanted to provide. character three pOSitions from left edge of the SCreen, then the window's left margin must be c.hanged peto r to PIUNTing. CR mus t be lese chan 0 r equa 1 to the window width as set by POKE 22,1/ and must be greater than or equal to zero. Like IIl'AII, tllili command can move the cursor beyond the right mars:!n of the text

-868 line from curaOt to right margin.
This is the

Clears current (E,scape E).

same as

~9C

E

711 CALL -922
Issues a line feed.

This is the ssm" "setrl

J

(Control J).

Window,
IJI!

but only long "nough to print Doe character.

60

CALL

-91Z

CV • PEEK(37)

SC~01l8 text up one lIne; i.e., moves each 11ne of text within the defined wind"", up one position. Old top .line 1s oat: old second line becomes line one; bottom line Is nOW blank. Characters outside defined windo,",",,0 not affected.

Reads

t.he current vertical position of the cursor and sets CV equal to it. CV 1s the absolute vertical position of the cursor and is not referenced to the top or bottom margins of the teKt w1ndov. Thus CV-~ is top 11ne on screen and CV-23 is bottom.
1411 POKE 37,CV Hoves

90 X - PBEK{-16384)
Reads keyboacd . If X>127 then a key has been preaaed , and X is ASCII value key pr easad '"'!thbit, 7 set (one). Th1s 19 useful 10 long programs, :l.n which tne computer checks to see if the user wanta to interrupt with new data without sopping program executIon ,
of l~~

the cursor to the absolute vertical position the topmost line. and 23 :1a t he bot tom 11ne '.

specified

by CV.

0 is

POKE -16366,11 Thts shou d

COMMANDS

AFFECTING GRAPHICS

Reseta keyboard strobe so thar oext character may be read in. be done l~diatoly aftee reading the keyboard.

COMMANDS
1111 CK •
PEEK(36)

THAT DEAL WITH THE CURSOR

Raads back the current horizontal posl tion of the CU~Bor and sets varioble. CH eq~al to it. CH will be in the range from II through 39 and is the

For purposes of dlsplaylng text and grapllics, the I\PPLE's m.. ory is divided m into 4 areas: text pages I and Z. and high-resolution pages I and 2. 1) Text page I 1s the usual memory area for all text and low-resolution graphiCS, as used by the TEXT and GR commands. 2) Text page Z 11es just above text page 1 in memory. It i9 not easl1y accessible to the user. Like textpase I, inlormation aeor ed ill text page 2 can be interpreted either as text or as low-resolution graphic., or both. 3) H:lgh-resolution graphics page 1 r.aides ie APPLE's memory from 8k to 16k. This is the area used by the RGR com .... , If text is aho"" ...1.h this nd page. it COrnea from text pag.' I. 4) High-resolution graphics pag!! 2 resides in APPLE's memory frem 16k to 24k. Th Ls- 1s the are a used by th.. 1lGll. 2 ceramand, If teKt is shown wi th ~hi8 page, it comes frDm text pag" 2.

130

131

1,., use the diffe~"nt grsph1CS and text mcdes , YOIl c an use A.PPLE50PT's t ext and graphics ,,,,mmands or you can opera te these 4 eli ffet"n t swi t ches , As w1th ..any of the sw;I.tehes d:heuaseel here. a rE;EK o r raKE to ona address sets the switch one "'"y, and a ~EEK or POKE t o " second addreea sets ehe "W1tah the other way. I.n brl,,·f, these 4 awl t chea choose between, 1) Text display (POKE -16311.3, II) a,nd Gra.phl~s display. higho,t low-resolution (POKE -1,63114.11) 2) Page 1 of text or high-resolution (POKE -163!i1I1,\l) and' Page 2 of t e x't or high-r ..so l ut Loa (POKE -1'6299,!I) 3):r"xt page 1 orZ for graphics (POKE -[,6298,,11) "nc! IIj gll-resolu tion page 1 or 2 for g rsph1cs (POKE -162 97 ,~,) 4) FuU-sc.reen nigh- Dr l""-Tesoluti,CI!'I graphics (POKE -163!i12.\1) and IUxe<i h1g,h- or l""-resolution graphlcs+t"l!t (POKE. -163\11. II)

LU: POKE -l63IlL.'
5"'1 tches from four 4~-eh"rac

full-sen,en graphIcs t er 11 nes of {ex tat

to mi.x"d-scre",o g raphf cs+rexe bottom of screen.

mod!!., w1th

Depending on the .... ttings of the other s'wluhes ,the u,pper portion o.f the 8C r'e en may sbow te,xc, lo .. -reaol" t Lon graphi cs on a ~ II by 4(1 grid, Or high-resolution graphics on a 27B by 16\il grId. Both por td ona of the screen display ,,111 COm" frQ!IJ the same P.·lle number (l or Z).

184 raKE

-163~(I.1I

15\1 POKE -163~4,

II

from Page 2 t o Page' I. wi t'!lout clearing the sc reen ormovi og the cursor. Necessary when you go into lnteg"r BASIC from APPLESOFT; ot"".:wise yo"", may !ltill be "Look.Ing" at page 2 of memory. Depending an the settings of the other SWitches. this can cause rhe display to change from high-resolution g:raphics page 2 to high-resolution graphics page I, f rOIll IOY-resolut1on graphics page 2 ro low-resoluti on graphiCS page I. or from text page 2 to text page 1.

Sw:l.ches t

Swi tches dt.splay llIode frOIll text to color grapnicswUhout dearing the graph:!".; sc ceen to black. Depending on the se t tings of the other J .... itches. the graphica mod.. switched co may be low-resolut.ion Dr high-resolution,. fro .. page 1 D~ Z,. and in m1,xed grsphic.s+text or' full-sc:r.e.en graph 1cs .

Sim,lar' APPLES OFT command.s': 'the GR co","",nd. ",,1 tchea t o page I law-resolution, mixed-screen graphfc.s+c"xt, and clears grapli1cG acre"" 'to black. The KG!!.cOllima,nd switches to page 1 I11gh -reSo 1u t :1,00, mixed-sereen graphic:s+rext, and' clears graphics sc reen to b Lack , The HCR2 command switches to page 2 h1gh-re.solu."1on. full-scree" graphic.s and cle'l'r~· ent1~e screeo to black. .

186 POKE -16299. 5,,1 tches from

~ P.~ge2. "ltho""

Pa,g.e 1 to

clearIng

the

screen

or

moving

the

cureo e ,
nepending On [he Sllttings 0.£ the ather swi t cnas , th,ia can cauae the display to change from high-resolution graph!'cs page I to h1gh-re.901ution gra'phic.s page 2,fIOIII low'-H.!loluti,on graphics page I to low-resolutiOn gnphlcs page 2, o'I from text pas" I to t!!.XI pase 2.

Switches d.l.Bplay mode frO!tl an)' colo'r graphics display 'to all text mode. .. !thou[ res e t tj ng scrolling, wi nd 0,", • Dependin& on the se re 111,6 of the Pag,", IIPage 2 swi tch , the' text page gWi e chad to msy be e1 ther text page I or tel!'t page 2.
The T£XT "'''nlOao.d 8.... echea to all 1 text ,"od .. , but 10 add1 tic" chooses page I, rese U IIc roll1 ng windo" to mal<imum and posit Ions cursor in left-hand. corner of TV d'isplay. texc 1011er

19(1 POKE -16298,.9
SwUches the pnge fof graphics from a h1gh-resolution graphiCS page to the lIame page oftexc. Wi thout cleari"g the SCreen. Necessary when you go into Integer BAStC froO\ ./l.PPLESOFT; otherwise the InteS,er llASIC Gil ins true ticn may 1nc.orrecdy show you the hlgh-,re.ooluti on pa.S"· Depending the Be uing& o.t the 0 thersv1tches. tld.slllay "au .. e the display hlgh-~esolutioD graphics page 1 to lo~-rc801ution graphics I, froll! high-reaolu t 10" graph:l "5 page 2 to 10,",-,,,,,0 lut iol'l, g.aphi "S pag,", (1n t ... mode) may c auae no ehange "t in the display. on

171J pOKE -I 63112. Ii!
Switches

to cbange
page 2. O~

fro.

from mixed-screen
the settings gr,sphics 192 Srid.

graphics.J.texc

to full-sere""

graphics.
as

Depen.dlngoo low-resolution on. a 27S by

of the other '9witches. thie nIO)i'appear as text. on a 4'~ by 48 grid. or as h:lgh-r"sa!ut1on graphics

195 PQ.KE~16297.1l' Switches the psge for gtaphi cs from II text page to til...conespood1og hl&h-resoiutioD, wi thootclearing the ac reen , page 0 f

132

lJependln,g on t~e ,se t tl "g9 of the other ..wi tcncs , t1da may cause the. d.i splay to change f 1'001 lo"-resolut,iongraph1cs page I to high-resolut ion graph! cs page I, from low-resol.ution grapll1cs page 2 to high':',eaolution graphics pase 2, Or (In tf)lIt mode) II1II)7 cause no change in the displllY.

t33

I211'11 CALL -1994

Clears the upper 2'1 l1nes of text page 1 'to reversed @ ,,1g0,8. If you are in page 1 low-resoluUon graphics mode, [!lUI cl ear's the upper4il lines of the graphics se reen to black. Has no effect on text page 2 or On high-.es:olu.t i on graphics., 2115 CALL
Cle"rs -1998

!t

26'1 POKE -16Z96,l s,,~ game control "annunciator" ope.,,-~ollectOI high (3. 5 volts) output 'II (Game 1/0 connector. • This is the "off" condition, pin IS) to ttL

211' POK£ -16295.0 Set g3."'" control output 10 to Tn. 1"" ( .3 vo,lts)" madmum CU,{ len t 1.6 1Ili111a1l\peres.

chis

is

the "on"

entire [e'lt t page 1 to reversed @ signa. H you a re in pa,8" 1 low-reaolution full-sen,,,,, graphics mode, tills dears the enU"" scree,n to black. lias no ,effee t On tell t page 2 O,rOn nigh-resol"t ion graphic's.

cond 1 don:

Z8\J POKE -16294. SOlt g,ame control

L output 'L (Ga .. e '[ 10 c oemeccor , pin le4)

zl1r;

CALL 624511

to TTL high

(3 •. 5

'volts),. which screen ycu
Hili Set POK£ -1.6293·.11

Clears eur ren t hig,h-reso 11,1 tionscreen (Al'PLtSOF'l' remembers used last. regardless of tile 9..-:1 tch settings) to black.

21il CALL

621,54

game control

outpUt

II

to TTL 1"", «(,1'.3 volts)"

Clears curren t high-resolu tl.'on 6<:'''''' .. n (APPLESOF'T ".. ember's ",hi ell screen y"u m used Lase , regard les9 of the 8,,1rcn aa ttings) to the Il.COt.OR mO. t 'recently HPLOTt n. Hust be preceded by a, p Lot, e

3(111 POICB -16292,1 :Set ga,me control oucput

12 (Game l/Ocollnec[or.

pin

13)

to TTL high

(3.•5

COMMANDS DEALING WITH GAME CONTROLS AND SPEAKER
22~ X .. PfJEK(-16136) Toggles speaker once: produces a "did." hom speak.e.r.

I

volts). Jl(li POKE -16191,0
Set game connoloutput

If

n

to ttl. 1"", (~.•3 volts).

32\1 POKE -162911, SH game control

I output 13 (Game I/O

225 X .. 1'££1(-16352)
Toggles
C89sette .... oucput

connector,

pin

12)

[0

TTL high

(3.5

vo Le a) " encer produce.s a, ftc.lick't 'on a ca08'e.tte recording,.

33'1 POKE 23~ X ..PE&I(-1&287)
Rea.ds be.ing pushbu'tton " .. itch on game "ontrol~Il,. If X>1.27 then thts

-1.6289, 'I conttol output to '1TL low {II. 3 volta).

Set ga_ buttOn is

pr ..,sed. "

COMMANDS
2411 x .. P££K(-16286)
S8"'."

RELATEDTO ERRORS
(219) • 256 where an

as above but

puahhu r ton on .~ame con e Iol

'1.

341:1)( ~ PEEK

(218) + PEEK

2SP X .. PE6K(-16285)
Gllme conuro l

Thts ,9rat,,,,,, .. nt sets X equal to, the 110e number of the statemen.t e:t":t"o~ occurred if 'an ONERRGoto stete,ment has been e.""cuted.

12 puahbut

tOil,

134

135

350

IF

PEEK (216»127

THEN GOTO 2000
Se[

AP LESOFT
SII1PLB

If bit 7 at melOory location 222 (ERRFLG) has been ONERRGOTO statement has been encountered. 360 POKE 216,0 Clesrs
37~ Y -

true. then nn

VARIABL!lS byte byte byte byte
STRING POINTERS tlAME (neg) 1st byte

POINTERS

ERRfLG so that normal
PEEK (222)

error cesssges

viII oc~ur.

REAL INTEGER $69-$6A r=lIAt~'fE~·~(~p~o=s~)~I~s-t~by--te-' NAHE (neg) ht (poa) 2nd byte (neg) 2nd exponent 1 byte high mantisss m.s.byte low mantissa 0 mantissa 0 mantissa l.s.byte !II

length address address

(pos) 2nd byte I byte low byte high byte !II 0

ARRAY VARIABLES

Sets variable Y to a code that described type of error that caused an ONEKRGOTO jump to oc~ur. Error type.s are described belou:
~6B-$6C

ERROR TYPE ENCOUNTERED,

o
16 22

~2 53
69 77 90

1117 120 133 163 176
191 224

254 255 380 POKE 768, Ig4
POKE 772. POKE 776. 223 72

~IEXT without FOR Syntax R&TURN without COSUI! Out of DATA Illegal Quantity Overt 10'" Out of Hemo,ry Undeiined Statement Bad Subscript Redimensioned Atray Oivis1on by Zero Type MislIlar"h String Too Long Formula too Complex Undefined Function Bad Re5ponse to an INPUT Statement Ctrl C Interrupt Atte~pted POKE 76'1,
POKE 773. POKE 171.

(pos) 2nd byte OFFSET pointer to next variable' add to address of this variable name 10'" byte high byee so, OF OUIEHSIONS one byte SIZE !lth DIMLNSlOtl high byte low byte
SIZE 1st DUlENSIOli

nAME

(pos )

REAL 1st byte

INTEC£R

STRING

POINTERS

HAllE (neg) 1st byte (o"tI) 2nd byte OFFSET pointer to next variable: add to address of this vllriable n_ame lov byte high byte no. OF DlI{ENSIO!lS One byte :; U;:; lit 11UUlt:N5lON higb byte low byte 1st OUIWSIOI'I high byte low byte tNTEGER% (1'.11 .... 0) high byte low byte SIZE

NAllE

(neg) 1st byte (pos) 2nd byte OFFSET poin te r to next vadable: add to address of this variable name low byte high byte NO. OF DUIEtlSlOtlS one byte
SIZE 11th
DlILEtis'[Otj

high byte low byte
SIZE

168
154 96

POKE 770, POKE 774,

104
72

l'OKE 771. POKE 775.

166
152

high byee 10\1 byte REAL (11.11 ••• ,0) exponent 1 byee m.s.byte .. IIotissa "",neissa man.tisso 1. s .byte mantissa REAL (1'1,1'1, ••• N) 1 byte exponent olllltissa m.s.b~te llUIncissa
mantissa $60-$61:

1st Dll!ENSION high byte low byte SrRUlG$ (!l.Il •.. ,0) le.ngth I byte address low byte high byte address

ItITEG&R% (II. tI, .. , II) h.1,ghbyte
low by t e

STRINC$

Establishes a machine-language subroutine at locatIon 768, whleb can be uaed 1n an error-handling routine. Cleara up SOme ON ERR COTO problems ",jth PRINT and ?OUT OF tfEtIOR\,RROR .. essagee. e Use the command CALL 768 In the, error-handlIng routine.

l"nsth address address

(R .11, .••N) 1. byte low byte hiSh byee

"",otis"a

l.s.byte

Strings lire stored in order of en ry. I ron HlliEli: dOl'n. String table points to first charocter of ~ach string, at the bottoe of the "tring in memory. As st~ing" are changed. new pointing IIddresses are "'ritten; vhen ava i Lab le memory is used up. house-cleaning deletes all abandoned strings. (House-cleaninu is forced by a FRE(X».
fill arrays

are stored with the rIght-most index ascendIng "10we8t; e.g., numbers In the ar ray A%(l. I) wheTe AI(!II.")~", A%(I,0)-I, A%(III,I)-2. I\Z(J,I )-3 would be found In l:IemoryIn proper aequen ce , 137

the

136

Appendix K: ASCII Character Codes
ORC DEC
ImK
u

HEX 411
41

CI!AR @ A B C D E f' G II I J K L H
N

WIlAt TO TYPE
@

CIIAR ilIa
O.EC

~ ASCU

a

ASCII

dedma1 code h.exadee11!i81 code from the
AfrLI> II keyboard

ASCll c.harac.ter name dinetly !lot aeceas1ble
CIIAR NULL SOB STX lUX E'I ENQ ACK WHAT TO TYPE

M 65
66

I:I.I:1K

DEC 32
33

HEJ( Z·~ 21

CHAR
SPACE

WHAT TO TYPE
spac.e

67 68 69 72. 7J
71;

II lUI
1 2.

etrl
err]

@ A

1{1 71

3
4

!II \'12

1,13

5

114

"tTL B "Crl C ct r L D etrl E ct rl f etTl C
c t.r I II or

s
7 8 9

liS 1,16

117
(18

BEL
liS
liT

1,19

1\1
11

!lA
IiIB flC

vr

Lf

etrl 1 etrl J enl K
ct r I L e[r1 11 enl N etr! 0 cn! P

RETUltN

34 35 36 31
38

22
23 2.~ 25 26

~
$ %
&

U

%
&

~

39
41,1
41 42

27 28

75 76 17 78
'79

I;.B 4D

42 43 44 45 46 47 48 49 4A

~C 4£ 41' 52 53 54 55
56

A B C D E F G II 1 J K L
H

N

12
\3 lli 15

!lD
liE

Pi' CIl:

16
11

Io1r
til
Ii

SO
5[ OLE

~

43 44 45 46 47
48

2A 2B

29

2C 2.0 2.E 2F 3(1

+

..
/

81J
+

*

81

83 M 85
86

82

511 5l

0 p

a
p Q R S

Q
R. S T U V W X
y

t

U

18

2a

19

12 13
Iii

De2
Ni\K SYN

DCI

21 22 23

IS
16 17

DC] DC4

etrl Q "trl R

49 SIJ

24
25
26

28 29 30
3),

27

18 19 II. 18 IC 1D IE If

ETB EM

c.t.rl S enl T etrl U e[rl V

o_:_["_

-

51

52 5]

ct.. rl

W

CAN SlIlI ESCAPE I'S

ccr ;
ESC

54 55
56 5,7 58 59

c.trl ~ cttl Z

X

31 32 33 J~ 3S 36 37 38
39 31.

(I I .2 3

II 2 3 4
5

/

81

4
5 6

89 59 gil 5A 9) 5.8 92 .5C
93 94

88 58

51

w
X y Z

II

z
\ J

(

7
8 9

6 7
8

SD
51! 51'

n/a o/a

I

(s.hift-H)

95

",In

9 c >
AS"ClIcode" in the range 9,6 throllgh 255 will genera te chsr"c ten; 00 the APPLE whiCh repeat thoae in the list above (fint those. in column 2, t hen the ent.Lr e series 8g".1n). Although CflRS (65) returns an A and CIIl!S(l931 also fatl).cns an A, AP.PLESOPT does not recognize the two· as the sa IDe character 'when USing string log.1<:a1operacors ,. and 11 p r in cer connec ted to your I\PPLB loIou1d pr int them dtffe r en tly.

n/a
ctr1 .ah1ft-M nrl n/a

611
6l 6Z

38

GS
liS

US

6.3

JE JF

3C 3D

138

t39

AppendiJc L: AP LE OFT Zero PGge Usage
$7D-$7E LOCATlON(s) (in hex)

Point,s to absolute.
DATA is being READ.

10ea[1on

in ",,'rnor)' f~om which
$2(11

Pointer Jump instructions to continu~ in APPLESOFT. (reset ~ returu for APPLESOFT is aquivalent reset ctrl C return for Integer BASIC.)
Location for USR function's See USR function description, General purpose counters/flags

$11-$5

to

to eur r en t source of INPUT. Set to during an INPUT st;atem.ent. During a READ s t a eeraant is set t·o the DATA 1ntbe program it is READing from. llo Ids the to lsst-uJled the variable's name. value.

SA-$C

jump instruction.
for APPLESOPT.

$B3-$81,

Pointer General Nain

last-used

variable's

$0-$17
$2!!-$4F

usage. pOint in accumulator. paint math rQutines.

APPLE 11 syste~ Genera.l

monitor

reserved

locations.
~A4

floating use

$5\1-$&1
~&2-$66 $&7-$68

purpose
of laat

poanr ers for APPLESOFT.
mu.I tiply /divide.

General Secondary Ceneral Painter

floating point

Result Pointer
oet to

$A5-$AB SAG-SAE

floating
usage to £lags

accumulator.

to beginn.ing of program. Normally $!l81o'!1 for ROM ve'r s Lon , or $30ill
tape) version.

Ipo:! n t en.

for RAM (cassette

$AF-B0
$Bl-$CB

end of program

(ncr changed

byLOM£N:

)

$69-$&A

P01nter
points unless

to start of simple variable space. Also to the end of the pTogram plus J or 2, changed With the LOlfEM: statement. to beginning of array space. storage
1n use. ar~

CHRGET routine. APPLESOFT calls here every time it WantS another character. Pointer
the

$611-$6C $6D-$6E

Pointer
Pointer Pointer stored General

$IIB-$B9
~C9-SCD

to last character CHRGET routine. numb"r. graphics

obtained

through

to end of numeric

Random

$flF-$71o'!
$71-$72

to s[ar~ of string storage. Strings from here to the end of rnemo~y. poin ter.

High-resolution

scratch

pointer

••

ONERR point.'ers Isc'C8tch. $EIi-$E2 Iligh-rcsolut.ion graphics X. and color Y coordinates. byte. graphics_ tabla. graphics.

$73-$74

1l1&hest location 1n memory available to APPLESOFT p Iua one. Upon inithl entry to APPLES OFT, is ae c to the highest RAMmemory location available.

$£4 $£5-$117

High-resolution
Ceneral POinter Collision use to for

g(sphics

575-$76
$77-$78

Current

line number of line

being executed.
a c tr 1 C. STOP $£8-$£9 $EA $P!!-$PJ

hj_gh-resolution

"Old 1:1 ne number". Se t up by or Elm ststePlent. Gives line execution was interrupted. "Old text pointer". Points for statement to be executed cuerent Hne number

beginning of shape
counter

number at which 1n memory

for high-resolution

$79-$7A

to location next.

General ONERf(

use flags. pointera.

$F4-$F8

f rOIll "hi ch DAIA 1s b,,:1ng REAll.

140

141

Appendix M: Differences Between
APPLESOfTa.!nd ilnteger BASIC
GOTO and GOSUB tIlun be followed by a lioe number 11110"5 lin arithmetic variable or elfpressio!t. Real var tab Lea and constants ("floating point" and/or ,,"'posenrs) are perm:1tted 1n AI"P~ESOF!
110 t

in APPL.ESOFT; Integer

BASIC

DIFFERENCES BETWEEN COMMANDS
The""
Al'H C!IR$ DATA EXP FLASH commands are availab Ie in

but

numbers nOt

Ln

w1 til decimal pont a Integer !lASIC.

APPL.ESOF'I, but

1n Integer

BASIC:

1" APPLESOn:.
81gnlficanc

COS
DEF FN DRAW

APPLESOFI). Significant .• String
IIIKI!M: IIOME strings

only the filat t""character. in a VOIdable name are (e.g. ,GOOD and ·GO[lCS are r·ecogllh.ed as t he slime v .. dable In Integer BASIC, all characters in a variable name are

by

FRE BG! INVERSE LOG IlG!t2

GET

HCOLOk

INT

ope.cat Lons ar e differently defined 1n the two languages. Both and arnys must be DIMensioned iil Integ")" BASIC, only ar)"ays are DII{ensioned in APPLESOfI.
1n APPLESOFT, arrays may be multl-d.imens101l31; liCliN,d to nne dto,enainn. in lnteger BASIC, arrays ara

KIDS

LEn'$

LOMEM: ON ••• GOTO ONERR GOTO
RJ;S lIME SE'C R.IGHTS SPEED

NORMAL ON••• COSUB R.&AD SCALE IAN.

ros

REC.ALL
SH!.OAll STORE

RESTOR E Snl

ROT

Af'I'LESOl't sets ctd B '[eturo. STOP
ele"'"n ts to

all
In

ar ray

elements

Integer

IIASIC,

to zern on exacur Lng RUN. CLEAR, or ,esec theuse·lI's ptogram""st set all array

sQa

zero.

S11'l~

USR VAL
WAll lQJRAW

When tbe asaer t.Lon in an Ineeger BASIC IF ... THEN •.. ae are ..e.nt evaluates as zero (fo.lse) ,only the ·11:1EN portion of the statement 15 ignored. In APPLESQI'T, all 5 ta cements follow1 ng a THEN a nd no. th e sam" 11 T1e w:111 be ignnred when the IF assertion evaluates a9 zern (false): program execution
jumps
'~D

t~he nex't

nu.mbe:.;"ed

p17cgr&m

line.

These
All'FG

eo .. !OOillda ar e available

1n Integ,,~

BASIC.

but

no t 1 n APPLBSOFI:

In APE'LESOFT, inst.ruction instruction, In IlPI'LESOFT.

the TRACE command di.splays the Une numbe r of each individual on a multiple.-instrt;lotion ·progra.m line, not JUSt the first 89 in Intege.r BASIC:.

OSP
HAN MOD

'Ih""" ate mImed dt Heren ely in Integer BASIC APPLESOFT
CLR C1.EAR

the

languases:

the CALL, PEEK, 111>4 POKE ""''''''''nds 1IilI)' usa the true range of addresses (II rhro,,&h 65535). In In teger 1I.I\SIC. locations IIIlth a(ld r"sse. gr ea rer [han 32767 muSe be referred to by t hei I [Wo's-complement negative value5 (locadon 32768 is called -32767-1; 32769
me:mory locntion

is

called

-32767; 3277!i1Is

"alle~

-32766;

etc.).

CON

COlIT

'UB

GOTO X.lijl+UIJ,1

GOSUB X"U!O+llJiI!iI CALL -936 I'OKE 5~.127 POKE S~,.255
X

ON X casus l0i1!i1,Hill, 12I11l 1 nOME (or CALL -936)
INVERSIl

lItAB (Note: APP~ESOFT also haa a TAB) ON X.GOTO HIli. i ia, 12!i1

END in a program whi"h atops on tile highest line number i.aop[1onal 1n APPLESOF'r., but required in all cases to avoid an error meassge in Integ.e(
BASIC. NEXT must be followed by is nptinnal In APPLESOFT.
,8

variable

name 1n Integer

1.11IS1C;
Ls

8

variable

name

NORMAl. XX (%

indicateS

inte&er

variable)

I

<> .!!.!. ><

In l1lt·eger BASIC, the "ynt8>< of ehe lNPUl Btatement fNPUI [string, j {var,}
If var 1s

gnblg.

OTHER DIFFE.RENCES
In I!Hegm: BASte,. the COITectn""S o·f a statem.ents·s syne ..x is checked when the statement is stored in ehe computer's memory (wheo you pre." the R6TIlRN key). In APPl.BSOFT, sucb checking.· is done ",hen" sta.t .... ent is e.xecuted.

• er 1"8 tNPUT [string;] {va r ,} If the optional string is omitted. string is present. no , 1s printed.

an ava r , then INPUT p~lntQ, a '! 'W'ith o,r w1thQ'.Jt the optional If vae is .. Bvs·r.,th"nno ? :Is ·printed, whe·ther 0·': not the Is pres,," bIn APPLESOFT, the "Y" ta" of the IN'PUT B t a te.m"nt

optional

is

APPLESOF! prints

a ?; if the optional

142

143

Appendix N: Alphabetic Glossary of yntactlc Definitions and AbbreviQfions
See Chapter
definitions.

eSC

'- a press of the Escape key, "",rked "ESC" e"pr
. ~ e,x·prcssion • m aexp r 1 sexpr

2 for a logic.al (a9 opposed to alphabetic) present,atioll of theBe The symbol: _, means "is at least partially deU,ned QS."

alpham • .meric.c.har8eter •- let ted digi t
a Iop :arithmetic logical operator

:- i1!llllediate-execution..>de < integer :[+1-1 {digit) Integers must be in tne range -32767 through 32767. When converting non-integers into integers, APPLESOFT may be considered to truncate the non-intege~ to the next smaller integer. Ho"ever. this is not quite true in the limit as the Don-integer approaches the next large~ intl!ger. For instance:

:- ANDrORI-I>I<I><I<>I<-I-<I>~I=>
NOT is not included operator aop

here on purpose.

.- arithmetic .- +1-1*111-

avar ,~ arithmetic variable :- namel,,"'meX All 81"ple '18r1,,,b1 occupy 7 bytes in memor')" 2 byt". aa tbe name and 5 bytes for tbe real or integer value. ._ av8'C subscript In arrays, reals occupy 5 bytes, integers 2 bytes. aexpr
: - ad thmetic expression :~ avarl real 11nteger fnr

AX·
123

123.999 999 959 999

PRINT A%

B% - 123.999 999 96
PRINT B%

124

ex PRW.

12345.999 995 999
C%

OX • 12345.999 996
PRINT DX

12345 (Spaces added for easier An array integer occupies

12346 reading) 2 bytes (16 bits) in memory.

:- avat subscript :- (ae.xpr) If parentheses are nested more chan 36 levelS deep, ?OUT OF MEMORY &RROR occurs. ._ [+I-INOT) aexpr Unary NOT app(!.ars here, along wi eh una [y + snd: .. aexp r op aexpr : - s axp r slop, aexpr

the

integer

variable
;- name% A real

name
may be atored as fitst converts an integer variable, but

APPLESOFT leuer line :linenum

the teal to an intece.r.

:- AIBlclDIElrlCIHIIIJIKILIMINIOlplQIRISITIUIVIWIXIYIZ
[(instruction:)]

character :- letter[digitlspecial ctrl :- hold down ehe key marked "CTRL" wn~le follouing named key is pressed :- defel:red~e"ecuclon mode the

rnae rue rf on re curn

deE

l1n.ou .. ,- line number :.. digit [{dig1 t)) Line number3 "USt be 1n the range ~ to 63999 or a ?S'(~rrAX ERROR message is displayed. 11 tl!Inl
;[(chlluc:ter)]

delimi tel:

:- -I (f) 1-1-1+ 1*1-1 < I> III , I; I:

A naee does not nave to be separ,Dted trom a preceding or follow:l,ng key word by IIny cf these deHmHetl10

lower-caae lettet :- alblcldlelflglhliljlklljmlnIDlpl'lJrlsl~lulvlwlxlll.
met.aname

digi t

:" 1121314151617181911l' 144

.- (metD9ycbol}[dlgit) 145

metasymbol :- Characters used in tbis docu",ent to indicate various structures or relationships 1n AP PLE SOFT , but wb Lch are not ps tt 0 f the language itself.
:B II[III{I}I\I-

A real whose absolute value 1s less than about 2.9388E-39 wll1 be converted by AP!'LESOFT to
z e ro , APPLESOFT recognize." tbe f ollowi.ng as r ea Ls when by themselves .•and "valuates them as ee rc :

presented +.
.E+

'. lower-case letter :- a single digit COncatenated
name

to a metam!me

.E +.E+.R+
is

+.E

-.E -.E-

.E-

-.E+

:- letter

A name

may he up to 238 cbaIacters in length. When distingujsh1ng one name from another, APPLESOFT iguores any alphanumeric characters af t er the first two. APPLESOF~ does not distinguish between the nameS GOOD4LITTLE and GOLDRUSH. ~ However, even the ignored porrion of a naae must no c ccncaf.u a special or allY of APPLESOFT·s reserved words.

1 (letter 1 digit) I

The array In addition

e Lemen c He.)

the Same as 11(~)

to the abbreViated teals listed above, the foll~lng are recognized as reala aod evaluated as zero when used 8S numer Lc responses to INPUT or as numeric ele.ments of DATA:
+ E +6

-E ~E+

space
-.E-

name

:. real variab Ie name name I name $ •- integer variable :- string variable
:_ 1111

E+

E-

+E+

+E-

nam.e

The GET instruction evaluates all of the singlecharacter real. in the above liats as zero • When printing a real number. APPLESOft will show at moSt nine digits (see exception, below), excluding the exponent (if any). Any further digits are rounded off. To the left of the decimal point, any zeros preceding the leftmost noo-zerO digit are not printed. To the right of the decimal polot, any zeros follOWing the rightmOSt nOll-zero dig"!t Bre not pr In ted , If there are no non-zero digits to the righ t of the decimal poin e, t.he decimal pOint is not printed.
"hen APPLESOFT

name

Dull "l:r1ng Dp

.•

operator

··80plalop prompt chaeae rer

:.

J

The right bracket, (] I 1s di9played is ~ready to accept a command. real
:I+I-J

®the exr reme At

1 1m1 r , round Lng is sometimes

curious:

1 EI+I-jdigicldlg1r) ) :- (+1-] [(digit»). [(digit}) [ E[+I-Jdlgi (digit) I The letter E. 8S used :In real number notation (a form of "scientific notation"). stands for "exponent." It is shorthand for *10Ten 1s raised to the power of the number on E'g rigbt, and number on E'. left i. multiplied by the result. {digit}
[.{digH}]

PRINT 99 999 999.9 99 999 999.9 PRlNT 99 999 999.9(1 l~G Gn (,1(1(1 PRINT 11.111 111 451 9 It. III III 4
PRINT

In APPl.ESOFT,reals must chrough iE3B or you risk mes88ge. Usjng addition msy be able to generate 1. 7E38 wi rhour receiving

be in the range -IE38 the ?OVERFLOW ERROR or subtraceion, you teals as large 8S chis ",o"9Sse. 146

u.ru

11.111 lI1 ILl 5

~51,1II!!

(Spaces added for eastor reading)

147

If a real's absolute value is grea tet than or equal to.llL and Iass than 999 999 999 •.2 the ~eal is printed in f1l<e·d-poiM ",otation. Th.at ls, nO exponent is displayed. In the range • II !Illl IJIlIl 1l~1l 5 to ." 999 999 999 r ea l s a r e fO' 1n ted vi th up Co tell d iSi es , .includ:ing. the .,ero immediateiy-Co the dght of the decimal point.. This is the. only e xcep t Lcn to the li,.,lt of n1Ol" printed digits,excluding the exponent , If you at t emp t to digits, su"h as use" real wi thmore than 38

special • "" special symbol used by A~rLESOFT n

.- !I'I~I%I&IT'I(I)I*I/I-I<I>I"I+I-I'I;.I,I·I@I?D

( (
subscript ._

Control ·characten. (char act er s Which are typed vhl1e holding down the CTRL key) and the null cher ace r are also specials. The tight bracket (I can be typed on the APPLE keyboard, but APPLESOFT USeS it for the pn'",pt char ac re r only. In this docu .. ent it i.s used as a .. "rasymbol .. (aexpr[{,aexpr}), 'The ,,,,x1.,u!Il number of di .. ensioos ( .. e"pt's) is 89,. a1thoush in practice this t s limited by the ext.ent of "" .. <lty available. aexp r must be pOSitive, and in use it is converted to an integer. st.rln.g
; I!I U

2Ll.llll1LIILlt111111111111111L1111111

then the message ?OVER F!.OW ERROR 1s printed, even if the real is clearly Within the range -I E38 through lEJ8. ThIs is true even if most of the digits are trail log zeros, as in

2.11.01J(fIHJIJ~IIIl!l1l1,J01l0111111~1l0PIl00il~1l1l01l001l

Lead:1 ng "eroes , however, are I gnor ed . If the U tea t dig:h ia .a one. and ~he sec ond d.1g.i t .is less than or eq...,1 to SiN, n... " ",bers .. ith 39 digits may be used vi thou·t gl>Ui fig an message.

·",',or

,-

A real real variable :'W n,.a,flJe

occupies narne

~ bytes

(~Il bit".)

in

memory.

({character)], II string occupIes 2 byteS (Hi b Lt s ) 11'1memory for its location poin.e" plus 1 byte (8 bits) for each char act er i n the string. '"I{char ae ted I tee". n This fOt'm of the at <ing can app"ar c.n.Ly at the end of a line.
it

at r In.g var f ab Ie

nam"

:,. nameS
9Vat :string vadable subscript The location poinu,r and v~r!oblc nam" "aoh oecupy 2 byt"s in memory.. The Lcngch and " .. d, s t dnS cha zaccer occupy on"

reserved "'0 rd ... certain groups of cl'ls'tnctetsuBed by APPL,ESOFT to speei fy i na true crcns 0 r porti I)n9 of :I nst rue ti ons , A naee mU5t not includ·e a re.5e"ved .. ord, Refer to Appendix ·G for a list oe APPLESOfT's reserved words.

:8 nameSlname$

byr e ,

Vat : - variable

;:.- ava r
I:"eto'[o

,18\16['

, .. a press ge"pr

.of t he key

ntH

.ked

"RETURN"

: .. at rin8express

ion

' .. sva r Istring
'. slop s.expr sop aexp r

,_ ·1>1>-1->1<1<-1-<1<>1><
B"!,

: .. s'tring.

logical

operator

metasy",.bol used t.o aepar at;e s l.ter na t Lvcs (not,,·:. lin i. tem "")' also be defined separately for each olternarive) met""Ylllbols used to end Ose OI4lter :jal wht eh is optional metHsymbols used to enc l.oaa m. te ria 1 whie h ""'y b" repeated .. ""asymbol used to enclose material whose value :Is to be used: the va Iue of K is "'rirceo h\ metlls),,"bol ",hieh indicate" II requ l rcd splice

:~ +

: .. SUing

operlltor

148

149

(

Appendix 0:
The inside directing cont atned

ummary 01 APPLESOFT Commands
an alphabetical index of APPLESOFT commands ( Il~T If program execut Lon has been halted by STOP, END. ctrl C or reset IilG return, the CaNT command causes execution to resume at the next instru"tloll (like GaSUl!)-- not the next line number. N"thing is cleared. At te r rese t ilGreturn the program may no t CONTinue proper ly because some program pointers and stacks are cle"8xed. CaNT canno t be used if you have a) modilied, added or deleted 8. program line, or b) gotten an error message since s~opp~ng execution.

back cover of this manual cencaaus you to the Dlore detailed descriptions in Chapters 3 through 1(1.

ABS(-3.~51) Returns tbe

absolute

value

of "the argument.

Th" example

returns

3. 451.

ar"I"OW'

ke.ys The keys marked with right and left arrowS are used to edit Al'PI;Eson programs. The right-arrolil key moves the cursor 1:0 the right; as it does, each character it crosses on the screen is entered as though you had typed It. The left-arro'" key moves the curSor to the left; a6 it moves, one character 1" erased from [he program line "'hich you are currently typing. regardless of ",hat the cursor is moving over.

L,IS ('

I

Returns example.

tbe

cosine

of

-.415146836

the argument, 1s returned.

whi"h

must

be in

radians.

In

the

lise

rrI ( Can be used to interrupt a RUNniog program or 8 L!STing. uaed to interrupt an INPUT if it is the first, character is no t i.Ilter rupted un tll the RETURNkey is pressed.
I

It can entered.

also be The INPUT

("QU1'.ST")

Ket'ur"ns the decimal ASCII code for the fit:st cnar ac t e r in the example, Bl (ASCII for Q) w:111 be r"rUIned.

the

argument.

'tn
"trl X Tells the A"PPLEl[ to ignore the lin" currently betng typed, without deleting aoy previOUS line of the same line nuOlbar. A backs lash (\) displayed at the end of the line co be ignored.

is

ATN(2) Returns the arctangent. in rsdiana, of the 1.1G714S72 ("radians) will be caeurned ,

argument.

In

the

example,
D' A IilliN ~Hl II. '(oDI 1 "

.j.". -,

CALL -922

Causes execution of a machine-language whose decimal address ls specified.

subroutine The example

at the memory location ,",ill cause a line feed.

Creates a list of elem.ents which can be used by READ statements. In the axatnp Le , the first element is LhO!literal JOHN SHITH; the aacond eleme.nt is the string "COOl> 32"; the third element is the real number 23.45: the fourth element is the integer -6.

CIIMS (6~ I Re turns the ASCII cnarnc re r tha t cor responds 100 the value which aus t be bl!tveen ~ and 155. the e!lampl .. retu~n .. the

DPr r
f the 1aeter
0

Al~) ~ w+w

argumeo t . A.

CLf.AR Sets all

variables

to

zero

and

all

strings

to

Dull.

cm.oa

Allovs uSer to define one-llne functions in a program. First the function must be defined using OfF; later in th~ prosram the previously DEFined function may be used. The e.xarn:ple illustrates holoTto daf tne " func ti.on FN A(W); 1~ may be uaed later in ~"e program in the form FN A(2J) or FN A(-7*Q+l) and so On. FN A(l) will cause 23 to be subs~ituted for W 1n 2*W+W, ~he function will eV8.1ute to 2*23+23 or 69. Assume Q-Z; then PN A(-7*Q+I) is equivalent to fN A(-7*2+1) or FN A(-13); the funcdon will evaluate to 2*(-13)+(-13) or -26-13 or -39.

11 Sets tlH' "olor for plotting in 10",-resolutiOn example. color is set to green. Color 1s set and their associated numbers are 8 bro,"", black ~ dark green 9 orange I magenta 5 grey III grey 2 daTk blue 6 medium blue 11 p Ink 3 purple 7 light blue To find cu t the color of a given point On the

grapha ca mode. to zero by GR. 12 13 l4 15 screen, green yello'"
S.qU8

In the Color names

lei

_• In the ",)(am1'le. To DELete a 9ingle type the line number

o

Removes the speci1'1ed range of 11ne8 from. the progra.m. lines 23 througb S6 ",tIl be DELeted from the program. 1Lne , say Une 3511. use the form. DEL 3511,350 or simply and then press the II £TURNkey. the SCRIl command.

white use

150

151

III AGf{2Q,31. N,\''1ES(5~) Wh'eo a DtH scacemeot 1s executed. it sets asLde "paCafOr the 'speciEied areays vith subscripts ranging from II t.hr ougn the giv<!nsubacr1pt. In, th~ e><ample, N,AME,H511)will be alloned 511'+1 or 51 strings of any Lengtb ; the anay ACE(2\l, 3) w111 be allotted (20+1 )"(l+l) or 21"4 01 84 number elements. If an arIS,y elemene is """d in a prOgH!m before it is DIMensioned, a ... x1 .. um sub sc r tpt; of 10 is a,110t"d for each dimension in ehe element',s subscript. Array elementB are set cc ee ro when 'Rill! o,r CLEAR a.re executed ..

,,,,,,,1

leop will beel<ecuted fo r Ii equa 1 to I, 2, 3, .,. ,211. e hen the loop ends ("Hh w-2 L) and the instr-ucUon"her NEXT Y 1. executed. Tb., second e"ample illustrates how to 1mlieate tbat the STEP s1.e 'as YOII count is co be different from j. Checking takes place at the end of the loop. So in the thlrd example". the instruction" inside the loop are executed cnce ,

~!,(J)

ll4I.A" 4 AT Sil. j.fl\.l Dr,,",s, shape deUni'tion nllID.be't ~ from a p'reviously loaded shape ta.ble. 1.n high -resolu[,ioll graphics. sra r Ung at x-S(J. y-Hl(j. the colo r , rota tiO!! lind scale of the shape to be drawn must have been specified before DRAY is execllted.

Returna the a .. ount of melll.ory, in bytes, still avail-able you. put. in.side rhe paren theses is un ilflpo r tan t ,. So long .. "valu .. ted by APPLESOF'I.

to the user. as 1 t can be

What

1-:'1) causes a program to message is printed"

GET A~SS Fetches a single character fcom the keyboard wi thouc sLI.o"ing it on the TV SCreen and "feho" t requidng, 'cha t [he RETURN key be pre.ssed. III the .,,,,ample,, the typed enarac rer 1s stoted in the variabl I'. ANS$.
;!JSLJI

cease

execuz tcn,

and ret urns

control

ee

[heuser.

No

.1.\1

~B A Ol e~~ H O~ e~e t or ~, n Tile E."ape Ir.eymay be used inconjuncUon "ith the ~et'ter keys A or II or C or D to mo..,,, thu CIHSOf w-:l rhout aff .. cH.ng the character,s movad over byteh" cur so r , To move the CllrSor one space, f lr;st press I:he escape k'ey", then te'lease chcesca,pe key and press the appropriate letter key, co~nd moveS cursor One space esc A right e9C B 10£,t "st: C down esc D up

Causes the progn ... to branch to the I ndf ca ted 11ne (Z51! 1\'\ the example), WIlen ,n RtlTlJRN statement 1s execured, the program branches to the sea tem"ot 1mmediately fol10w1ng the most recently e",ecuted COSUII.

COTII 25" Ca.u"". the

p<og~&" to branch

to

the

indic8ted

1:I"e

(2511 In

the

ex.amp1e).

[,Ii

Sets low-resolution 1 ines for !teKt at !!loved into theeeK

GRaphics ",ode (411 by 4(1) for the 'tV screen, the bottom, Theacreen 1a cleared' to' black. t window. and COLOR 1 s set to 0 (black) •

leaving four the. cursc r is

. P(

I

ReturnB places,

t:be varue e -2.716289,

ofe
80

raised in the

to t:he power :Indicated example' 1.38911561 ",Hl

by th" argument. be r e t urned .

To (;

i L.IHi!

Se tS ehe vi dee mode. to ..£lash ins", sorhe,

ou cpu t from the computljr is a1 ternate 1)' shown on the tv se teen 1" "hi t e che r a c ["rH Dn blao::k (lila then re.ve rsed to bf ack cna rae te rs on 3wh i te backgr eund, Use NOII.MIIL, return to a non-fl8'shing display of "h1[(' l('tters on a black b"ckgwund.

to

1\1 Jl.Ol< ~ S,,'t6 hi gh-resolutioll graphics color to the n6."'''S and 'the ir associ ted: va lue6 ilre black. 1 4 blaclr.2 I gree" (depends on TV) 5 (depends blue (depends on IV) 5 (depend'a J ..h f t e I 7 1o>1I1te 2

color
TV) On TV)
Oil

sped f1ed by :HCOLOl\.

Color

o

'0 \,-! 10 .if ,., Nt , ,/ FOR Q-2 TO -3 STEP -2... t<EXT Q FOR Z-5 TO 4 STE P 3... NEXT AlIo"," ~ou to vd te a "loop" to perform a specified nuober oE. timeS any instructions betv"en the 'FOR conroand (the top of the loop) and the NEXT command (the bo t tom 0 f the loop). In the f1 r s t exaap Ie. the vat iable " counts how "any rimas to do the 106tructions; the instructions ills:!d.e the

Only avaUable in the f1 versioo of APPl.~SOPT. Sets hish-resolution graphics m"de (2a~ by 16(1) for the screen. leavIng four lines for text at the' bottom. The screen 19 cleared to bla.ck. and psse I of 'memory i.o d t sp Layed, NeLther IlCOLOR nor rcxe ac eean memory is af Eac ted wilen 11GII. 1s executed. Th" curso r 1s 'DOt moved Into the. text ",indo,,_

nnw.""

152

It Set8 fllH-screeo cl c8.redto black not affected.

and page

high-tesolut1on 2 of

grophics node (laG memory is displayed.

by 192).. The sc ruen is Text scree" memoty is

153

H1MI!M: 11»1:14 Sets the sddress of' the highest memory location avs.ilable to an APPLBSOl'T progrlllQ, includ.ing var·1able,s. It 1sused co pro rec C an ar .." oimem,ory for data, nig,h-resolution sc reens or machiue-language rout Lnes , ElIMEM, is nor reset by C!.E.IIR, RUN, NEW, DE!.,. chang!I1g or adding" program Un.", or reset.

second ex,ample,. INPUT pdnts the optional string exact Iy as shown • then wnits for the use t to rype a number (which ,,111 be assigned to the real variable B) then a comlll8." then string input (which ",111 be a.soig"ed to tbe string variable C$). Mul t l p l e ,entri",,' to INPUT may be separa ted by eomeas or rle.t;Orll:S~

IfLI:l III. 211 AT 111 Used to dra" horizontal lines 1n 10w-resolutioI1g[aphics mode, usd.ng the color most recently specified by COLOR. The ot1gin (,,-~ and Y'-'~) for tho syste.m La the top left,most dot of the SC,!:een. In the e"ample, the lil\e is drawof rDm _HI [.<,x-2\1 at ),-30. Another "ay to say this: the line is drn"", hom ~he dot (111, 30) through t he dot tlll, 3\1}.

'lIlT (KlIl4)

Retut"" the la.rgest 10tege[ less than Or equal to ebe g.iven argunent . In the example, if N1JM is 2.389, the" 2 will be r e cur nad; if HUH is -IoS.1Z3345 'then -1;6 will be returned.

,1(V[;RSE

lI()1.;,E

the video mode so t.ha t the computer '" ou'tput prInts as black letters On II whi te background. Use NORMAl.to re tUln to wtl1'te let ter s On a black

Seu

MDves the
and "lear

cursor

.. all text

to the upper l,,£[ 1n tnelo'ind.,,,.

sc reen

post ~ion

within

the

text

"indo".

background.
PI {"

ItPLOT TO 7'1. eli Plots dots and 11nes 111 high-resol'H 10n graphics mode us ing the ",os t re"en tly specH led v8~"e of "COLOR. The origln is the top leftmost 9c.reen de t (x~4. y-~). The ffrst e.>I;ample plots a Mgh-Tesolution dot at )(~lll. )'-Z~. The s"con.dOl:xample plots a hlgh-resolut{ol'! line ftom the dot at ,,-311, y-4'(I to the dot at y-6i;L The third example plots a line from the l.ilst dot ploned eo tbe dot at ><-7(1, y-81;1, using chI! color of the la8t dot plo t ted, not ne"es."a rily the m09 r r"cent IICOLOR.

HPLOt 3(1, 4\1 to

IH'I n I~ •

.l'

5!J, 6(1

Spec1fle.s the 91,ot; (hom I through 7) of the peripheral which will be prol!iding subsequent l<lput for t.he coeput <!r. 1111 0 .[e-e"tllbl ish ell input from ~he keyboll'td instead of the peripheral.

".~!I,

Li'fT ~ ("A PP'L r SOFT", 5) Re turns the .. pee Hied ",,,,,bet of Lef tOl08·( example, APPLE (the .5 leE tmosrcharacters)

cha rae t er s ftom the ...1 U be return.ed.

s c rIng,

In. the

.Lf'!ft

~!'r

oW

Inu .::) Mo"es the eursc r either
on the at reenIn the

Se.e iiar':t"ou keys'·'. left or figh t to the sped Hed co luem CUUO,[ wi 11 b~ po at Ii oned (I
ill

exall!ple" the
(

th t:ough A\1) colU!!lI! 23.,

If,v;t

~

IIEM

,a-I,

.1

E. "AN 4PPI \ I' ") Returns the number of characters example. I~ will be returned.

In a Btring,

between

0

nnd 255.

In

the

IF ANS$ ..,"YES" THEN GOTOl1l0 IF 1I<l1AX" IIl&N 25 1F II <li:A.X COlO 25 If th".xpress!oo foll<)wing If ... "luate " .. as true (i.e. non-~ero>, then ~h~ :InstnJct1on(a) follo .. Lng THEN in. the same Une ...:lll be executed. Oth",..,:l8" , any 1n~truct:lons fol1cw:l"g THEN are ignored. and .. ".o"tion passes to the, :Instruction :Inch", next "u"bered l:lne of the prog.[am.. Suing el<pr".Qlona ate evaluated by alphabetic 'ranking. Exal!rple,g 2, .3 and 4 behave the Slime, despite the d1ffere,n,t ""rdings.

I.[I Ii 2).. '<,7 AS .. ''DELICIOUS'' The "ariable n.am" to the expresa ron to t he tight

0

leIt o~ f the ..

is assigned the value the LeT is op tional.

of

t.ne strlng

Or

.51 LIS:r :!(I(I-3\11l11

UST
11U'I T A LNPU:r"TYPB ACE THEN A COMMA TIlEt! NMfE ": II, C$ Incne f'lratexomple, INPUT p,r1nts !I question mark and W'l!its for th" user type II nUl!lber, "'feh w111 be assigned totn" iMeger vae lable A,%. In the

Zn,.301i11l

to

The first el<a ..plc causes the whole program to be displayed On the TV acree".; the second ""ample cauaee p~og (am line.s 2~1l til rough .31300 to be dl"pl ayad , To list Ira", the start oE thl> I'~osra!!! thr"ugh line 2(JIl, use L.IST -21l(il ; to U 9t fro'll Hne 2!J1l to the end of the pr08r"",." use LIST 21111Thethi td ,e".ample behll"es the same as the ""cond ""ample. LISTing t s .borted by ctrl

C.

154

155

[I,AD

(JIHJtR

core

5 (.I

Reads Sn APPLESOFT program from oassette tape into the computer's memo.y· Ilo prompt is given' the user must rewind the tape and press "play" on the recorder before LOADing. A beep is sounded when information is found on [11 tape being WAOed. \-IhenLOADing is succasaf.ul Ly completed, a second beep will sound and the Al'PL.ESOFT prompt chau.c:ter (]) will re turn, Only resile can interrupt a LOAD.
U(; (_)

Used to avoid an error message that halts execution whe.n an error occurs. When executed, ONERR GOTa sets a flag that causes an unconditional jump to the indicated Hne number (51il1il, the example) if any ecror is Lat ar in
e.ncountered.

rm, (1)
Returns the current value, a number from" through 255, of the indicated game control paddle. Game paddle numbers 0 through 3 are valid.

Return.s

the

natural

the example,

logarithm of the specified .693l47L8l is rerur ned ,

arithmetic

expression.

In
f (37)

1" lEt!: 2 ,11 Sets the address of the

Returns address lowest memory location available of variables from high-resolution
of memor-y.

the

contents, in decimal, (37 in the exampl~

of

the byte

at the

specified

decimal

This allows

protection

to a BASIC p~og~am. graphics in

computers

'loTi

th large.

amount-a

1'1.0) HJ. 1\1 In low-.esolution

III 0 S I "AN AI'PU. A 1M\ '" ~ 1 HIDS ("AN APPLE II OilY". 4.9) Returns the. specified substring. [1'1 the first example, the fourth through the last characters of the string will be re rurned : APPLE A DAY. In til" second example, the nine charec te rs beginn:!ng With the fourth c:haraICCer:ln the string wil be returned, APPL.E A 0

graphics mode, places a dot at the spec1fied location. the example. the dot will be at x-LP, y-20. The color of the dot is determined by the most recent value of COLOR, which is (I (black) if not; p revJ oIJ81), speci fied.

In

I'I)~" -1f~fII·. II Stores the binary equf va lent of t he aecond argument (~, in the example) into the memoI'Y location whose decimal address is given by the first argument (-1631il2,in the example).

Nf,

Deleres current
IjJ

program and all variables.

XT

See the discussion
!illll 11AL Setll the

of FOR •..TO ...STEP.

One RETURN address to "pop" off the top of the stack of RELlIRN addresses. The next RETURN encountered after a pop causes a branch to one statement beyond the second most re"ently executed casus.

PO CallBes

video both iuput and

mode. to output.

the

usual

white letters

On

a black

background

for

Returns the cunene horizontal positlon of the cursor. This is (I number from 0 (at the left margin) to 39 (at the right margin). What you P"t in~ide the pe renchesea is "Dimport8nt. So long aa it can be. evaluated by APPl..ESOFT.
, '~T
II

~1l"111

Tu nS off the TRACE

'" TH~!

mode.

See TRACE.

n,' [) )~ Exe"utes a GOSUB to the l1ne number indicated by the value of the lII'ithmetic expression following ON. In the exa~ple. if to is I, COsuS 100 is executed; If 10 t s 2, GOSUB 2011 is executed, and 80 on. I the vaLue of the expression is II or is greater than the numher ot 1tsced alternate li"e
nuebe e s , then program execution p['ocee:da t.o rhc next state.rnent~

'H 1"".

~'1...

.~

PRlNt AS; "X - Hi X The UI'5[ "-,,amplecauses
screen. Item" in a list

line feed and recurn to be executed

on the

ON.

ON If) {If( IU~, 1111\1, ·,\lII~. ,!It! ldenti,.,,,1 to ON' 10 casus (see above). line nu",ber indicated by the value of

n.

wi 11 cause OOREX • ) to be printed.

to be PRINTed should be separated by commas if each is to be displayed in a separate tab fjeld. The items should be sepaI'8ted by semi-colons if they are to be printed right neKt to each other, without any intervening space. If AS oonta1ns "CORE" and X is J, the second axamp Le

but execut es a GarO branching to the the arithmetic expression following

156

157

Transfers output to the specified to the TV screen.

P'k

slot,

I through 7.

PRO"

returns

output

,-..w executed, s assigns ~. e When
B•

the variables in the READ statement successive vslu from elements in the program's DATA statements. In the example, the first two elements in the DATA statements must be numbers, and the third a string (whfch may be Ii number),. They ,,111 be assigned, respectively, to the variables A, B%, and C$.

8

RND(5) Returns a ranaum real number greater tban or equal to " and less than t. RND(i) returns the most recently generated random number. Each negative argument generates a particular random numb"" that is the same every time RNDis used 101 that argueen e, and subsequent RND's, wabpos1tive th arguments ..ll always :follow a par rt cul ar , repeatable i sequence. Every time RND 1s used .. j~h any positive argument, a new random number from I! to I is gene raeed , unless it is part of a sequence-;;¥ r ando .. [lumbers initi a ted by a
negative argument.

1101

~ 16

Retrieve .. a real

!!(,ALI '1:or an integer array "'hicb has been STOREd on cassette tape. An array may be RECALLed Ideh a different name than used when it VS8 STOREd on tbe tape. When RECALLed. KX must have been DIMensioned by the program. Subscripts are not used w1th eithel: STORE or RECALL: in the examp Le., the array whose elements are MX(~), MX(l), ••• will be retrieved; the subscriptl"ss variable I1.X well! not. be affected. No prompt or oehar aigna! is given: ~ou must press "play" on the recorder when RECALL is ""ecuted; "beeps" signa.! the beginning and end of [he recorded array. Only reset can

Sets angular rotation for shape to drswn by DRAII or XDRAW. ROT-I! causes shape to be DRAWnoriented just as it was defined. ROt-16 causes shape to be DRAWn rotated 9(1 degrees clockWise, etc. The proceu repeats starting at ROT-64.
I1l1N 5(111 Clears all variables. pointers, and stacks and begins execution at the ind1cated Hne number: (5~1I in the example). U no line number 1. specified, e.xecution begins at the 10lleSt numbered line in the program.

interrupt
'i'J'IISAR1IA!(

a RECALL. SAVl'.

StOt... a program into a progrnm
8S

Allows
p

text to be inserted

remarks.

On CSsSe t te tape. No promp t O.I &ignal is &1ven: the user must press: "eacoed" and "p l ay" on the recorder before SAVE is c.xe.cuted. SAITE does not check that the prop .. " recorder buttons a'C" pushed; "beeps" signal the start and end of a recording.

If you hold down the repeU key. labeled key, the character Idl1 be repeated.
~ slO1I1.

r

REPT.. while

preSSing

any charec ter

SCALt:-SIi

Sets scale size Ioe
f01;

shape to be dra~n by DRAW or XDRAW.
shape

ResetS
next first

the READ

au

"dats

list

pointer"

cement encountered

to the first element of DATA. to re-READ the DATA stlltements

Cauees the from the

point rep[oduct1on of the plotting vector being extended and not a single point.

SCALE-l scts point definicion. SCALE-255 results in each 255 t1mes. NOTE: SCALE-" ia maximim size

One.

At the end of an error-handling routine (Bee ONER.R GOTO) , cau .... the S resumption of the progu.m at the statement :in which the error occurred.

( r.SUNr.

seR'1(III. ) 2 In low-resolution graphics mode, returns po Iut . In the example. the color of the
_'U!1i(!iLtI)

doc

the color code of the specified at K.l~ .• y.211 18 returned.

~. II

Branches
GOSUS.

11

Returns -I if the argument a'8u", ..n t is positive.

is negative,

II

if

the argucent

Ls II. and 1 if

he

to the statement

immediately

fol10"108

the most recently executed
"HI nAil

M1C~n S. • ._ .tt P' I ... \ I Returns the sped fled number of rightmost ~baractefB the example. APPLE (the 5 rightmost characters) will

Loads a shape table from casseete [ape. Shape table is loaded just below HlMEM: and then HIHEM: is sec, to just below the shape table: to protect it.
from the string. In

be returned.

I', ) Returns

I l~r See Ira r-tO'W

""

.9Q9297427

the sine of the argument. is returned.

which muSt be in radians. 159

In the example,

keys ",

158

S1'1.(8)

Hust be used in a PRINT statement. [ntraduces the speclried number of spaces (8. in the example) between the last item PRUITed and the nexc :l t~m PRINTed 1f semi-colons precede and follow the SPC command.
SrEED 5ijl

ntACE CaU5es the lloe number of each Statement to be displayed 0[1 the screen "'S it is execuced , TRACE1s not turned off by RUN, CL&AR. NEW, DEL or reset. NOTRACE t urns of f !RAC E.
USIL 0)

Sets rate at which characters 8~e to be sent to the screen or other input/output devices. The slowest rate t s 0; the fastest La 255.
SQI' (: )

Ret~rns the positive squate root of the ar&u~enr; 1s ret~rned. SQR executes more quickly than -.5
SlOP

in the example.

1.4142135&

This function passes 1ts argu",ent to a machine-language subroutine. The a rgumen t .is evaluated and pu into the floating-point ac.cumulator (locations $9D t hcough $A3), lind II JSR location $0A Is performed. Location$ S0A through S\JC must contain a JMP to the beginning location of the machine-language subroutine. The return value for the function is placed in the floating-point accumulator. To return to APPLESOFT. do an RTS.

°

\AL("-3.7E4A5PLE")

C.auses a program to cease nxecur t on and d i spLay 8 mes9age telling what lioe number contaIned the STOP. Control of the computer is returned to the UBOr. "'rulu PIli Records an integer or real array On eape ,
is

Attempts to interpret a string, up to the first "on-numeric character, as a real Or an integer. and r"tutllS the value of that number. If no number occurs before the first non-numerIc character, II II 1s returned. Ln the e>:ample. -37~Il'" 1s returned.
\'LUI 111.2\1 AT 311

No prompt measage or other Sigl1f)1 provided: the user must preas "zecoru" and "p l ay " on the r eco rde r 'When STORE is excc.u cd. "1I""p." slgnal the beginning and cod of the ~.. ocd:lng. c TIle subscript of eh.... rray is not indicated When STORE is used. In the r

example. the elements KX(~), HX(I). MX(2), variable MX is not affected. See RECALL.

... are saved On the tape; the

in lO"'-"eBolution graphics mode, draws ..vertical line tn the color indicated by the most ~ecent COLOR statement. The 110e \s drawn in the col .... indicated by t.he thi rd arg u ment. n In the e xamp Le , the line is d,awn from y-l~ to y-2Q at "c3Q.

vrJ.lI(lS)

'fRS[l2.4))

Returns II string that represents the string "12.45" is returned.
T!lB(23)

the value of the argument.

In the ex.. ple, m

Moves the cursor [0 the line on the screen specified by the a,gllmen[. The tOP Line is line I; the bottom ine is line 24. VIAB will move the curSor up or dOVll but not Laf c or right. WAlT J fiWIl, 255 WAIT 16(;1\1~. 255, 0 Allows" conditional pause to be inserted into a program. The first argument 1s the decimal address of a memory location to be cesced Co see when certain bits are high (I, or on) and certain bits Dre low (Q, or off). Each bi r 10 the binary equivalent of the decimal second argument indicateS whether you're interested in the corresponding bit io the memor}' location: means you're interested, , menns ignoTe that bit. Each bit in the b nary equival~nt of the decimal third a~gument indicatea vhich state you're WAITing for the corresponding bit in the memory location to be in: 1 means the bit must be low, ~ means the bit must be high. If no third argument is present. ~ is assumed. If anyone of the bits indicated by a l-bit in the sacond argument matches the state for that bit indicated by the corresponding bit in the thitd argllml!nt. the Wi\IT is ovnr .
XDUII ) AI 189.1211
g

Must be u s ed in a PR UIT statement; the argumen t mllS be between ~ and 255 t lind enclosed in parenchelles. For "l:8uments 1 through 255, if the argument is greater than the value of the eur een t cursor poa! cion, then TAB movea ehe cursor to the specified printing poa1t10n. counting from the left edge of the current cursor 11ne. If the argument r s Less than the value of the current curSOr position. then the cursor 1s not moved. TAli «(;I) pucs the cursor into position 256.
TA.' ( )

R turns the tangent of the argument, which muSt be in radians. example. -2.185113987 1s returned.
HIT

In the

SecB the scre"" to the uaua l.non-graphics text mode, w1th 1,1jl characters J1ne and 2~ lines. Alao resets the cexc window co full screen.

per

160

Draws shape definition number 3 from a pr.eviously loaded shape rable , in high-resolution graphics beginning at x l81l, y-1211. For each pcfnt plotted. the color 18 th..complement of tI"1(, color already ex1st1 ng at thllt point. Provides an easy ... to erase: if you XDRAW a shape, then XDRAW it again, ay you'll erase the shape without erasing the background.

161

INDEX
Cosine function: See COS

A
AlIS L(l2. 15(1 Absolute value funCtion: see ASS Accuracy in dIgits 4, 5, 7, 18 Address 411. 41, 43-45 aexpr 34. 134
a Lop 33, 134

c
43, 52, 13~. 134, L511 Cassette ar rays 62-64 shape tables 97 loading APPLE:SOl'T 1\16, Ifill memory range 118 Chang" program 11ne 54, llfl-ll/t Character 7, 311 ASCII codes 138, L39 strings 19-21, 59-61 CALL CHR$ CL6AR 69. ISII 8, 52. 1511 Colon 1\1, 125 DATA 68 GET 66

Cotangent function 1113 Cui (Control) 35. 144 Cursor position 5~-5l, 54, 55,

F
Firmware Ai'PLESOFT 1116. 1!1l7. 1(,19 Fixed point notation 4 FLASH 53, 152 Floating poin~ notation 4, 12~, il,l FN 73. 74, 151 Format 4-5, 18. 22 FOR ••• NEXT ·11-14. 211, 78, 79, 152 Full screen graphics 84, 131-134 Func t ion 73. 1I;!2-1~4
FRE 53. 1:;3

I HI-l1~, 131

D
DA'IA 17, 68. 69, 141, 151 Debug lIKlde 411 Decimal places lB. 22 De.lmal tokens for keywords 121 DEF 18. 73, 74, 151 Deferred execution 2, 36, 134
DEL 49, 151

Alphanumeric char ac r.er l~, 134 AND 33, 36,. 144 aop 33, 144 APPLESOF"r BASIC loading 11l6-1~9 converting to 124, 125 versus Integer BASIC 142, 143 in fir_are 44, 1116, i~7, 1119 on """5ette 1116. 1118, 1119 Arctangent function: see ATN Arccosecant fuoction 1(13 Arccosine function 1(13 Arccotangent function H13 ArCgecant function 1113 Arcsine function III) Arithmetic operators 33, )6 A'Crays 14, 18, 32., 56 memory allocation lt9 memory map 126, 127
STORE, RECALL 62-64

G
Game controls 11.9, 1.53
7.

Delay

loop

27. 41-43,

97

90. 134, 135

Delete 3, 38, 49 Delimiter 33, L44 Differences between 85, 1511

GEl' 24, 67. l!>3 GOSUB ••. RETIIItN 15, 16, 79, 8~, GOTO OR 76. 81,. 153

INPUT
5,

66

COLOR

Color 23-27. 65, 89, 13L-13/, Columns! see tab fields Comma
DATA 68 CET 66 INPUT 66 PRINT 6,

i i, 24. 25,

APPL.ESOFT and Integer BASIC 142, 143 Digi rs 4, 5. 18, 22 reel numbers 31-33 DUM 14, 58, 152 Dimensions: see DDM Division 2, ie, 33. 36 DRAW 92. 97-99
Dummy var Iab Ie 73

program
5, 11,

speed
23-25,

12Q
84. DI-LJIo,

Graphics 5, 1~. 23-27, 83-1U0. 126. 131-134

153

H
lICOLOR 26, Hexade~1mal
HOR 2:;, 153

71jl

saving space 116. 119 zero page 1411, 141 Arrow key. 54, 55, 1111-114. ASC 611. 1511 ASC.U character codes 138 Assertion 9 Asslgmnent statement 8 Asterisk 2, I'" AT 6. 25, 86, 98. 152. 154,
Ani 18, 1~2. 123, 15(1

Command 2, 122- 123 Concatenation convening to APPLESOf'T
PRIN1: 71 SPC 52

E
121,

1511

strings
CONT 39. 40.

21, 7L
67, 151

Edittog 54, 55. 11111-114 Element arrays 14, 32, 58, 62-64 DATA 68, 69
E!ID 16, 39, 116. 152

27, 89,. 134, 153 codes 136, 139 26, 84, 87, 89. 98, 99,

Control chara<ter codes 128 Control B 106-1118 Control C 7, 111.35. 39, 4\1,
161 1\17-11119, 151 DAT.\ 68 GET 67 INPUT 66 LIST 48 Control H 67 Control Ii 6&,

avar

33. 34. 144

Equals algn 9, 12 Eusing programs 3. 3B the sc reen 52 Error 115-117, 167 ONNERRGOTO code type ESC 35
esc esc A, B, E, F C. D 131il 54,

HOR2 25, 810, 88, 89. 99, I;) High-resolotion g~aphlc8 25-27, 87-II!(I', 131-134 m.em.or, cange 126
zero page II.l HIMEM, 41, 43, 44, 99. 1\1", 1.23.

127. 154 81, 136
tL(I-114 HLIN HOME 6,

u,

25, 8~, 154 48, 52, 154

HPLOT
HTAB

B
1\16-1\19 BASIC loading Branchin8 casus L5, 16. 79, BII, 153 GOTO 76, 153 11-14, 78, 79 loops

26, 89, 98, 131-134, 154 27, 511, 5t, 154 Hyperbolic functions 1(1'3, 1(14

Control X 55, 66, 69. 151 Converting to A.P.PLESOFT 124, 1113 Cosecant function
COS 18.

69

125

isz,

Bxecution 2, 36, 38-·45 E:XP 18, 1113, 152 Exponent 4. 5, 18, 31-33 Exponent function: see EXP
expr JS, 145

IF ... OO1:0 IF ••• THEN

151

lm~dlate Incrementing

76, 154 9-LIl, 76, execution

154 2, 36 in loops 13, 78

162

163

INFUT

Input/Output

7, 9, 66, 67, 141., 154 38, 62-74, 126 game controls Bod apeake.r
91l., 134-135

Inserting pauses 4., 42 eexe 3, In, 114
INT

LOAD 38, 156 Loading BAStC 196-11'9 Loga.rithm function: See LOG LOG L8, 11'3, 156 UlMEM: 44, 45, 123, 121, 156 Looping 11-14, 2g; see FOR••• NEXT

Nu~l string

19

ASC 6(,1 DATA 69 IF .. , U!EN INPUT 66 ~nD$ 61

R
16, 17 Random n~mber function: see RND READ 17, 58-71l, 141, ISS Real 4, 5, 31-33

Low-resolution

graphics

84-87

Integer

rounding 18 31 variables 18, 31, 145 Int"g,,~ BASIC ve.rsus Al'PLESOFT
142, Internal 119 143 routines

102., 155 2, 4 ~al~ulation.. 36 INT function 19. 1112,

19,

Number Number

4, 5, 18, 19, 31-33 format 4, 5, 18, 22, 31-33

calculations
DATA 68, 69 variable names

18, 36

M
155

Machine language 45, 92-97
lIantissa

o
subtoutines 43, .COSUB 8L. 1:;6 ON••• COTO 81, 156 ON·ERRGOTO 81, 136, op 34, 146 OR 33, 36
ON.,

lB, l1il2, l1il3.

Interrupting execution 39. t.!il INVERSE 53, 155 l"verae hyperbolic functions 1114
Ioverse trigonometric !1il2. 1(13 IN' 71, 155 Iteration 11-14 functions

4 Margin setHngs 128, 129 HA, converSIon to Al'PLESOl'T lZ5 tlatrix: SI!e Array Memory 2, 8, 4(1, 41 error me.ssage locatcion 81 lIOR 87 HCR2 map 126, 127 remaining 53 storage allocation 119 zero page l4g, lU

141,

157

Output,

video mode.

53

as

p
Paus a 27, 41-43, 97 PDL 911. 157 PEEl{ 4(1. 131, 134-136,

18, 33 RECALL 62-6_, 158 Rela'tion bet"e." exp reas.tons 9, 35 REt4 8, Ig, 51i1,UB, 158 Repeat key (REPT) 55, 111-114, 158 Replacing lines 3 Reserved words 7, 8, 3B, 64, 87, 14B liat 122-123 storage allocation 119 Reset 35, 39, 4\l HIMEl!: 43, 44 LOILElI: .4 RECALL 64 RESU!~.E 82 stopping a program 39 STORE 64 RESTORE 17, ]1iI, 158 RESUME 82, 15 ce curn (RETlIRN key) 2, 3, 7. :35 GET 68 INPUT 66, 67 PRItlT 71il RETURN 15, 16, 79, 811, 158 RIGHI$ 2(1, 6L, 158 Right-arrow key 54, 55, 11(I-1l4,

157

K
Keyboard
Keyword 13(1 codes

121

wetaname J~, 145 metasymbols 3(,1,145 MlD$ 21il, 61, 156 converting to APPLESOFT HOD 1114
Nodes

Peripheral devices 126, 134, 135
PLOT 5,

71, 72. 9(1,
l57 23-27, 84-11il1l,

Plotting
1.24
POKE

iiI. 5,

24. 85, 1~, II,

a

L
l.EFT$ lU'-11~, 29, 61il. 124, 155

debug
axeeut
f

4(1

on

36

13L-134 41, 48, 128, 129, 131-136, 157 full scre ..n graphics M, 87, 88, 131-134

Left-arrow LEN
LET

key
IS\!

54, 55, 67,

Monitor memory
return

Pointers

aa,

52, 69. 7(,1 8(1, 126, .•

range 126, 127 to BASIC 1\17, I(lS

19, 59, 155

8. 12, 72, 155 Line 2. 3, 36, ll8, 141 Lines In graphics mode 86, 89, 92-97 Line feed 7(,1 13~ Line number 2. 3, 35. 49, 165

shape tables 92-97 ze co page 1411. 141 Hoving the cursor 51i1-52, 54. 55,

127. 141il, UI POP 8(1. L57 POS 51, l57

us-u«,
111, 125

L31

Multiple

statementS

per I1ne

P,ecedence of operators 36 Program 2 zero page pOinters 14(1, 141 PRIm: 2, 6, 7, 7'1, n. 157 strings 2!1, 21
TAB 51

27., 1!il·2, 141, 159 ROM-APP.~ESOFT I!j!&, 1117, 11,l9 RO, 92, 97-99 159

15(1 RND ia,

Rounding
RUt! 2,

4, 5, 18. 19, 31-33
la, 39, 159

8.

5
SAVE 38, 159 "pace 118-119 SCALE 92, 97-99, 159 Scientific no orton 4, 5 SCRN 87, 159

byte size
DATA GOTO

118

Multiplication

2, 33, 36

i.tsr

68 76

48

N
name, name%, name$ NEW 3, 8, 38, 156 31, 33, 34" 146

SPC 52 Pro~t character
PR' 72, 158

35, 84, 1(16,

108

Saving program

ON •.• GOTO 81 .ero page 1411 linenum 35, 145
LIST Literal 4, 48, 155 19. 34, 145 DATA 68, 69 It,PUT 66 3,

Q
Question
INPUT PRINT Quotation DATA

NEXT 11-14,

20.

78.

79,

12Q, 156

NORHAL 53. 156 NOT 33, 31" 36 NOTRACI': ,411, 156

mark

7, es, 67 71J mnk 66 19, 34

Secant llil3 ."xpr 35, 148 Semi-colon 3~, 33
I~PUT 56, 6]

LET

72

INPUT
str1ngs

69

PRLNT

6, 7~, 71

164

165

S(lN

1112,

159 159

svar '>

Shapes

92-IGlJ

SI:lLOAD92, 97-IGII, Sign.ificant digits Signum, see SGN SLN 18, un,. 159 Slash 2', 36

Syntactic definitions :l~:-J6 .. lphabetl~ed 14~-1'9

34, 149

w
"AIT 101, 42, 161

?NEXT 1I1THOUT FOR
7B aexr 79 ?OUT Of DATA READ 71J FOR ll6

116,

Wllldow

5~. 51, 7tJ. 84,

128,

12~

T
711. 7L 51), 51 TAB 51, 16(1 vtAll 51! T~ L8, IG2. 16G Tangent functioll' see TAN :rE;lIT 6, u, 84, 16G T"xt 6. 24 and graphics tl, 131-1)4 ,. 16~
HTAl! Illl

Tab

X
fie.lds
XDRAW

slop

Sloce sop 34. 148 Soni ng IS, Space saVers

35, H8 0 thru]

71,
23 118,

71
119

){PLOT

92. 97-99.
123

J61

RECALL 64 STORE 64 ?OlIT OF m:MORY
DIl:! 58 GOSUB 79 IIUI.El1' 44

H6

Z
Zero p.age. 1411, IH

SPC 52, Speaker
Spedal SPEW Speeding

16{1 134, 135 symbols 3G 54. Hi!!
up tbe. prognm

LOllfJo(, 44 ?OVERFLOWERROR 33

,,,,,.is

116

SQR

II-D,

18,

lG2,

1611

Square root fU>lcti·oo' See SQII. STEP 1J, 79, 15Z STOP 16. 39,. 1611 Stopping a prog.",,,, 7, 111. 16, Storss"

38,

39

alloc.ation

I t9

"'indo" sa, 51, 7~:. 71, !28-l3{1 THEN: see IF •••THEN TO: see II.PLOTllnd GOTO Token s for keywords 121 TRACE 4(i1, 82, 161 Tr 1go nome cd c fUnctions l8,

1JJ.emory

r8.".8"

126

84,

ERROR MESSAGES
?BAD SUBSCRIPT 1.1 7

I (iI~-l!14

STORE
STR~

62-64,.
21, 22,

1611
59,

1,6\1,

Strings ASC

ems

18-B, 34 6(,1. ISII 6{1. 15(1

u
USR ~5, 161

DIM 58 ?CAt! 'T CON1:INlIE 115 CONI 4G ?DIVISION BY ~ERO 115 ? ElCfItA tGNOR EO GET 68 INPUT 67 1FORMllLA TOO COMPLEX 116

STR$ 59 VAL 59 ?REDUf"D ARRAY DUi 58 ?RI:EH'IER lliPliI 66

ll6

?REIURN WITHOUT Gasus 116 R6TURN alii ? StRING tOO LaNe BRROR 116
LEI'! 59 PR11lT 7 L VAL 59

lF77
?ILLEGAL DIRECt 115

?SYNTAX ERROR ASC 6~
CON! 4G DATA 69 DEL 49

U7

concst"naticn 2l, 52, 71 convert[ ng [0 APPLESOFI 124, 125 DAtA 68, 69, LSI !F ••• tHEN 16, 154 INPUT 66, 67, IS4, 155 LEFt 211, 611, 155 LEN 19, ~G, :;9, 155

v
VAL 21, 23, 59, 161 "a>:" 3S Variables 7, ·8, JI-JS arr.ay 14, 58 FOR, ,.NEXT loops

INPUT
?ILLEGAL
ASC

67
QUANTITY
61J

115

CALL

elmS
12., 13, 78,

43 6(1

FOR ••• NElIT eET 68 IlGR 86
H.GR2 68

7B,

79

s

LEI 72, IS5 m.emory 53, 119,. J 26, 127, 14~, 141 !>lIDS 2(1, 21., 61, 156 null strings 19. 6G, 61, 67, '69, 76, 71
RECALL 62 -64, 158 158

INPUT· 7, 9, 66, 67,. 71 in [eger 18, 19, 31 LEI ( - 1 8, 12, 14, 72, 73 names 1, a, 14, IS 31-35 program Ilpeed 12~ RE.All,. DAtA real 18 17, 68-71l

79

DRAJ.I 98 HIMHM, 43 I!PLOT 89 IlTAB 51i HI' 72 L£'1$

IF ••• THEN
iNPUI 67 LIST 48 RECALL 64
RESLfHB

76,. 77

ON., .GOSUB

~11O$ 61

611 81

ON ... COTO

BI

RUN III SILLOAD 1~!I SIORE 64 7TVPE MISHATCH LEFT s 6G

82

RIGHT$ 2~, 61, STOR €62.-64, 160 STR$ 21, 22, 59, 16G substring 6G,61
VAL 21, 23, 14, 59, 15. 34, 161

sa vine; spa".!! 118, 119 aninI! 18 z arc: page L4iil. 141 vee ro r 92 -96
lI"ldeo VLIN6,. VIAll output 53 25, 86, L6L 27, SQ. 161

Subroutine.
S"bs.cript

16. 22, 6G, 61

79, 8Q
58

POL 9~ PL.OT 85 POKE 41 RIGHT$ 61 8Ft 52 SPEW 54 Sl'ORE, RECALL \'LIN 86
VTAD 5~

u;:cr

B4 III

62

Substriog

LET 73 111D$ 61 RIGII!S 61 ?UNOl;l" 0 FUNC!lOU DE·f 74 ?UNDEf'D STAl'El-IEIlT

II?
IL 7

WAIT

41 167

GOSIJIl 79 GOTO 71> nUll 38

166

CAST OF CHARACTERS
" S % • + ,, f 9, 3!l1, 34, 66" 67, 69, '11 18, 39, 34, 6~. ~I 18, 311. 31 2, 3\J, 36, l!ll6 4, 5, 311, 32. 36" 65, 68 4, 5, llf, J2, 36, 66, 68 2, ,6, 3!i, 33, 66-71 2. JIiI, 33,. 36, US 3(1, 33,66-69 6, 311. 3), 66, 67, 711, n '1" 311, 65, 711 31J . vi, 311, 35, Ul6 3(1, 33, 36

\ 1 -

I

311

() ()
()

311. 33 14., 30;1,. 33. vii, 311
Vii, 3(1

119

• as assignment 8, lZ , as prompt character 1!lI& -, >. < 9, 3IJ, 33, 36
&

12.3

168