@L|}6CD l0C)HCC WhL/h `CmCDiD`  R@W1  Y0@R !L` D  C D     )16CS S)  C)D1 p p 0 C9DI pCDL~CiCDiD` D  C D     )16CS S)  C)D1 p p }0 C9DI pCDL~CiCDiD` DD˙` d J)L !}D L(( LL()  L| L( S LH 0p n  } CY?  q  L L  ` )} `A! d߰")-݆ "  $G@LLL&0") $G% }H0 3S8`G ȱG ȱG   Gȭ Gȭ GG}GHiH8(()) G$H% `(0 })8` d)L ݆ & LGȘ ݆LL d  ! LL d)N>Q  HH) }  hyhyB q L> Lm JJ  Ln*` dB%' }8  H H` 1 { LL   !L     Hh SY?  q  1L }  !? S   q 1 L   Ll  Lg E`L   !L)  q 1L}) `L0AM݊L݉ ML  N݆LLLNLMLHG!@}1F GȱGLLEEȩÑEȑEEȑE Ed E7EȩE  q} L !,0,0SGɛ L 1 !L EHEh W G gLLSROTCES EERF } G) *Gȩ GȽG GȌd q q G`  8   0G  `D}CEDC0X:Ȣ Y ȱC* ? 0.. , 0%n ?A[ 0 : L`L  `, 0`Y}`piH n0)բY? 08`0 }  0$L GGȽG L `8L`L}8`  05G)݁,G)ȱGȱGHh0})Hh` B! 8`8iiiLE`}E8FEh( l0`ɃLL L8^~jj8jHi hEEEiEȱEiE` dTE} H8EEȱEEȩEh J E8   . m  i`LI!)E1FR}1LJ舩9GIH`LJJ`HGHh l`} S gL   8 rii `дCDCG W  }C  Lq` X٨`DOS SYS IIIIIIIIIIIIIIIC`0 ߩ0}}} HE |||||DOS DOSDOS SYS }}}}CDOS SYS} 0`BDELV !B }`LVUQ   ]   TU J ]L!T  #      TU  } L ? .  t`GBJ V~DEHI B V0dV!}QDEHI VF9 ,0 ,0 s0hhL  L` H hDHEh"}DEL8HI   0 HI,0 0  9 .G VLO#},0 L4*IJ`llD1:AUTORUN.SYSNEED MEM.SAV TO LOAD THIS FILE.D1:MEM.SAV J y08 B|DEHI$} V0 0`B;DELV䌚 !B y`@ʆ v s? F0Ξ05: [ BDEHI%} VY8 B V  @  /DE `E:D1:DUP.SYSERROR-SAVING USER MEMORY ON DISKTYPE Y TO &}STILL RUN DOS B;DE J V (` 9 V⪍ ઍ  -'}LLu DEHILV 9 .l 9 .l  `` s$B VBH(}I|DE V BLV nB,DE J V* \*` B V BLVDEHI BLVL)}1u H232435; 1 ;  hh@2 e1i1LHҍ 00) 08 109hh@ Ҡ2e*}1i1232435ޥ<<8} THIS LESSON REQUIRES THE BASIC ,} CARTRIDGE. pppG-}A| BASIC || BUILDING || BLOCKS || || Copyright 1.}983 || MECA | Program loading. Please wait. Hit any key to bypass introduction.E:A/}8  L1/01"/L. B VB婁DE J V R B ߂0} ߂ ߂+ ߂> ߂Q ߂d ߂w ߂ ߂ ߂ ߂ ߂ ߂ ߂ ߂R ߂ ߂`DE1}HILV ``CkCLnCLCLIELXEnCiD !"hhhhh8Jm8 |ʈ"! `2}h˅h̅ Cαe͐ͅLCHH` (D)xҩ2ҩҍҩC`έCC`CC̠3} Ҍ҄`:̱)p LDC)C)CCLD)jDeECLDC̱?8ɿ<)? DHDH0 CLD4}ChhҭLD`LDLD4X~(T0pPP&p J h045}Pp!#%( *- 0258;?`CGxlCmCX`xeEX`HfEzEhllCҥh@@1@62@6} (@恩 (@Lq`Ll@@$$L'2&$&"'%L$%o$j%$$$$$$$$$$$$$$$$7}$$$$$$$$P$Q$R$$ $ m$mn$.'l$/'m$$R$Q$P$ll$HHH2ҩҩ*Ҡ %hhh``H8}#$hl$HHH#$#$ |%EO%N|%EO%N ԌЌЍ5#$$n$' k%%' (hhh@  9}  t  2&&"'(:}]]] իͫͫTµµ궾ǶʶUUUccc;}AEEvvvMLLpppzyyɢ ` n$ ( ( ( L( (x( $X`H@()<} 0 ɟ IH)?h&HhgM0+hh@M$gLY(n$'' (=}hh@''Xɧ ~$L2 $L- )$O$ z/ԍԭ$0$1)>}*$"$#$$$ԩ"/` )$L)$ zԍ$$/ԍԭ0$1$č0*1!$"$)%?}"$#$"%#$ԍ ԩ"/`*10$0$1$$ (`E;˅̠@}̦*+?N; -MECA BASIC Design ToolV? -Stack: Level= Top=;˅̩L$|˩(e˅˩e̅L$%h$0A} g$e$f$i$j$k$ 0 1O$L$$ h4 $:`ppp̥?˥?E;˥?m;˥?B=>˥?B-?˥?}?˥?A*B}+ ,tep%xecutethenextstatementC}race%xecuteallstatementsinorder0ressanykeytoendtrace5senumerD}ickeyspause, - throughfast tovaryexecutionspeedxit2eturnE}tothelessonape2eturnto"!3)#F} -.3witchbetweenthe"$4screenandthe"!3)#screenG}˅hhΠ :9eͨeHH` * @)@_$[$ .EntH}er command or press ? for he./lp-HHLm.)?&L.L;/> .>StepL/- .>Trace (speed=1)Y$Lm2I}*L2 $) MjjjL.;L.'}?}?`hhΠ[$ȱ :9}?L.R$(ʝ}?R$eͩͅeHH` z*+* J}.Enter command )// zm*;* .Enter command or press ? for helpL. (e$f$g$h$i$jK}$k$ THTh{I{L$ 0 / 1 4 $:` / 0Z$Z$ @)`ݺ/ `+0 ()$Z$ (`0L}& x$ $L0ȄH /h  L/0/0 L,0LQ0Lf0 n$'˽'̱HȱH` $ $Յԅ $ 0hihiHH`LM}$ $ {$L/0`` $ $ԅ $Ƴ {$`e$f$g$h$i$k$j$ğ'0)eeN}ȱ0ȱȄ` @) h4 $: $L-'01> Y1X^=Y_ ,1 1` Y1X^>Y_ ,1 1` O1ȱ إ󅕥O} $ $`'X`$%$ʥ%$ʭ%$ʭ%$ʭ%$ʭ%$ʥ{%$ʠ %$ʈ%$ʈc%$ʵR%$T'SRP}]UGK$FJ$2GLF`$%$ʽ%$12ʽ%$ʽ%$ʽ%$ʽ%$ʽ%${ʠ %$ʈ%$ʈ%$cʽ%$Q}RK$GJ$F`US`H2H`HhK$HJ$H`Y$ U$8HU$U$V$)jjj .;! S90:L@) :9}?8YR}$Y$8V$U$ /c$) @)`Lm2 ($l$W$<23W$(3U$ȹ3V$` d E7'ˈ|ˈ O$S}ˈ n7`H)I@U breakpoint if <=<>>=< > = hF3 :9 n72& V3 :9 O$ȽV3 :9 O$`h |7S$H$ (T}$hL 4L3H2& 2&ʩ2&h :9ș%ș%ȌT$ 7h$ T$%34T$ 7 T$%ȌT$8S$T$S$0' :9 O$ȑS$숱)U}$"( O$LL4)$ ( :9 O$ȑˮS$T$Ƚ% O$T$`L$HL$ 3 4L$hL$ E7_`L$HL$ 4L$hLV}$` E7e˅˩e̩̅ˈ n7`H)I@hh E7 n72&  2& 45˩e˅˩e̅L$ n7L$ |7H n7 6h$Lu5W}2&֩ץͅ΅LU6h 71H)#hT5 :9ˈ`not yet dimensioned h0L5L5͕Ԉ ؠȱ0ȱH) :9h` X}n72&Ƚ2&Ͱ%Ƚ2&Ƚ2&Ͱ 6ԅͥՅ΢Lu5ȹ5 :9`elem56ent out of range n72&2&ՠͅȱͅ᥌Y}e्eȱͅȱͅȥȥ ȥͰeͥeΥee8ͅԥ΅Ր Aˈ0 :9Z}ˈ`) U$ mU$iͩi&`N$ i"ͩi'`2&2&2&2&٠ͅȱͅ67օנJ uve[}ԥeՅ&եԤ&eԅԘeՅՠeԅȱeՅեeԅԥeՅ`̭L$ &e˅˩e̩̅me˅˩;e̅`L$ mL$2&`?)M$\}ͥΥń兰(M$0ȱȘeͩͅe΅L7ȱ)`8`)M$έM$ & & &eͥe78Υň`2&2&ՊH خ]}T$ȹ0ȹH) :9%hT$h`]$ˈ _8ɛ`~]$ˈȑL08 :9]$L08\$^$@_$a$ ^}S9`$ɀLl8Ɂ ^$I^$Ll8ɂ_$Ll8Ƀ@_$Ll8Ʉ_$Ll8a$@`$a{ _$ a$Lx889`$9 M^$`$\$9_}  $Ll8`0123456789+-.E~}~R$H****)h)69R$` @`R$H****)h)O9R$`@ `R$d9R$`lj;k+*opui`}-=vcbxz436521, .nm/reytwq907~8<>fhdgsaLJ:K\^OPUI_|VCBXZ$#&%"![ ]NM?REYTWQ(9:)'@}FHDGSA { a} ` }c?j?X$Ő呐L;ͥ8ͥΠ#q: :9b}j?!GOSUBFOR/NEXT from v: :9j?~: :9j?Hͅȱͅ hȱ0ȱH) :9j?h:D;X$ 8 c}ͥΥͥΰ8ͥL:X$ԩ ؠȱ0ȱH) :9c?h`$ (L<; @)jjj`'|cLL}LL#d}L*hL$ $_$$B]DE JK V BZD!EJK VCH B VhɊ!1[!`]!a!e}HzHdGL hqq \lCmC iC`E:HEAD hhhԍ|!f}L]!.^!͎!!! %! = a!DiL iC"!!`hhhԍ|!!"g}$ fCL E]! %! = a!W! & r$b!Lu$h!!" !!`%W! h}& Lo$S!U!V!`|(&r!!}!I[! `2[! }! `1[! }!r! `UI BgD!E'H V $i}`'T BZD!EJ V B V( { L $˭$̩ &ˈUI B!!˝D̝E'H j}VUT`ԩ ؠȱ0)`!0_!`0_!a!`%D2:L.06LISTŠˠΠŠĠԠ٠@##k}!!!hhh˩! # #L#\ ! #L*#_I0!L*#!! #I0L*# ̕!`"l}!!%L*# ݗ!ʥL#!!!`RUH BD!EI V &!!!`PP??m}??n}?????~~PQ???o}`????~Á~?p}??8||?QRq}pppF`zARɯ qLqͩ`ΠΥhԩ`2Lr}z/0R1"/`ԩ$oЍЍЍЩ>/Щ cC000      s}RS HP8d((P8e(PP8f(xP8g(0ͩ )ziIP`ЍЍЍТt}P8d(P8e(P8f(ͥR`ͩ )ziP`xЍЍТQ8d(@Q8e(hQ8f(u}STRͩ )zQaxЍЍТQ8d(Q8e(Q8f(եRͩ )zv}QapЍЍТ@|d{******* !&+05:?******* "'},16;?****}{{|}-)#2/%$5#!4)/.#/20/2!4)/.}/&!-%2)#!(R THIS LESSON REQUIRES THE BASIC -)#2/%$5#!4)/.#/20/2!zz4)/./&!-%2)#!(RpIJwTOLELINKPTRESETVMOVEMABUZASCSCRSCRSCRBRANCHELMABEGIKE}  }?6-AtY6-AuH'6-Aua36-BrH?6-Aud+A@";@,+6-?:,Zy6-A6-A}'6-A36-AP?6-AK6-AW6-Ac6-o6-@y AC %@@}/%@@C%@@H%@"@e.%@#F:A`,E%@$F:Aa,H$,/ %}@@/%@@6H%@#@e.%@$F:A`,E%@%F:Aa,H$^v%@@}+%@#@eB%@$F:A`,Y%@%F:Aa,m%@"@p(s(v$T+AR!0@}K6-F:A`,%F:Aa,$AV%@Q-T$X66-?:<,F:,!A(.6-F:,&A(2 6 bF:,"}Al F:,$A%A6-?:--(%Press any of these keys, at any time,C%"(to jump around the lesson.%(M9(}Key Jumps To:(6(Ԡ Table of contents9(Wf&(à Beginning of the Chapter)(C(  Back One ScreenF(c(}Ơ Forward One Screenf(k0&( Returns From Help Screen0(zQ-@#< '}NB YA(Q$4 4 (ɠàŠƠӠ=@@!-@!7 }: = && && | Introducing BASIC |$&& |  BASIC Design Too}l |.&& |à Branching |3&& |Ġ Input/Output |8&& |Š Decisions |B}&& |Ơ More Branching |L&& |Ǡ Arrays |V&& |Ƞ Functions |[&& |ɠ }Strings |`&& |ʠ Disk Input/Output |j&& |ˠ Sticks and Sounds |t&& |̠ Graphics } |&& O@@!-@ O (堠}@(@@K:4AFA@dXAdAUe)@p@|A}(6-&A(!@6-&@24@:A,*@:L,4 A %+&@:A,,$AY-@@ 4 }ŭҡ̠=6-?:,K-AO Y AP 4 (àL6.INT}RODUCING BASICP Q*(" -(Q(This program has been carefullyMM(Edesigned to presen}t key BASIC commandsand concepts by allowing you to b6(.observe actual programs while they execute.9(b($BASIC Buildi}ng Blocks is constructedO'(to build advanced concepts fromO(#simpler ones, so become comfortable p-(%with each chap}ter before you move on.0(p(:Now we'll show you how easy it is to review any topic as **(often as you like.&6-@}*  P 4 (à젠®L6.BASIC DESIGN TOOLP  *'( Ԡ}*( L'(As part of this package we haveL( included an exciting new program J'(called BDT (ASIC esign ool).J(B}DT acts as a window into your P*("computer letting you take a normalP(!BASIC program and slow it down to M*("your spe}ed while observing programJ(variables and their values.M( R+(#BDT hides in your computer's memoryR("along with your }BASIC program. In 6&(fact, it's in there right now.26-@6 H 4 (砠î}D6. BRANCHINGH p,($ /(p(:@4, Hello there>:@4,'/(,(! is a ./('cP(HT}he characters used in a string can beany characters you choose, such asc(ñ etc.*6-@  *P 4 (}ʮL6.DISK INPUT/OUTPUTP ++(( +(*+PP(HSince you }have a disk drive, we will assume that you know the basics of4+VS(Kusing disks. There are two things that you will nor}mally use disks for.V(H+b(-("(1) To and programs, and0(R((2) to and data.^6-@b .P} 4 (󠠠ˮL6.STICKS AND SOUNDSP ./,($ /(}/RR JThis chapter deals with those elementsof BASIC that make programs more fun/&# to write and easier to use.& 0/-- }%The statement lets you beep and:/H toot or even play music.# H  The joystick and paddle-handlingD/bR Jinstruc}tions, , , and give you input without typing.^6-@b 2G 4 (󠠠}̮C6.GRAPHICSG 2N+(# K( N(2PP(HIn this ch}apter we'll look at graphicson the ATARI. This will include a2jj(blook at the graphic modes which allow us to put differe}nt size and colored letters on the screen."36-@ D2:HEADEGIKENZ[+u%%LETOHEATOEXALINKPTKENPRINOURPRINSCHITKEGOBDBRANCINKEBDSCRCAADKEB }  } 6-@36-AuU6-AuR'6-AuH36-AuX }i6-A6-AP'6-A36-AP?6-AK6-AW6-AP]6-i6-A(a6- }6-@3;A,;@9,a6.' \Z A$67B:,%,.!6-?::A( }%@:,,9@ ? B$)& >:A(%@:7@<@,,,)$,A-@@#= " to move on or for }helpA ^>-@@#> # for or for help 6- )"@:B,'6-&@) AP }"@:F,' AP0"@:T,'&6-?:,0 A*"@:C,' 6-?:,* A> }"@:?,)"@:/,6-+%A(46-?:,> A ( $'6-&%@A AAA }A A0A@APA`ApAqAuAAZ@(@@K: }5)@@@L!A(Z6-&A(!@6-&@2$&;+ -; ( }0]6-?:<,06-F:A ,%F:A!,$AV>-@V%$@A(%Z ]$    *I }AR) What is your choice?- 4 >:,FAR@I >'@:=:,,  ' AH   }$ 6-?:, A 6-?:,LYAR!-@@ I " to move on or for helpU6 }-@Y j j6.\9GETTING AROUND\\Think of this lesson as a book. Each screen is like a page. But here is mm6 }7B:,%,.[where the similarity ends. The benefit of a computer for teaching BASIC is the simple and oo67B:,%,.]rapid } movement anywhere in the tutorial.\\Movement commands are located on the help screen. hh67B:,%,.VPress or to see } them. From the help screen press the space bar to return to this WW67B:,%,.Escreen.\\Why don't you give it a try...b }ut be sure to come back here.6   : :6.,After you know some elementary commands you ll67B:,%,.Zwill lear }n to interact with the computer in a controlled environment.\\You can experiment &jj67B:,%,.Xwith actual example progra }ms we have written or you can write your own.\\Before you are 0kk67B:,%,.Yintroduced to the power of BASIC Building Blo }cks you need to learn the basics of BASIC. :FF67B:,%,.4You'll learn:\\ b   }8 86.*7THE COMPUTER REMEMBERS\\A computer does cc67B:,%,.Q what you tell it to do and nothing more.\\I }t holds instructions and data mm67B:,%,.[in its . When the computer is on, its memory is active. When you turn } it off if foroo67B:,%,.]gets. That's why programs and data must be stored on disks.\\When you type a BASIC program, }ll67B:,%,.Zyou are storing the instructions in memory.\\The computer will not do anything with these dd67B:,%,. }Rinstructions until you tell it to. You do this by typing and pressing RETURN.*    > >6.07NUMBERED INSTRU }CTIONS\\Each BASIC  hh67B:,%,.Vis numbered, and BASIC always instructions by line number order. W }e usually  ^^67B:,%,.Lnumber the instructions by 10's (10,20,30,...), but you can use any numbers  aa67B:,%,.Oyou } want in the range 0 to 32767.\\This is a typical line in a BASIC program.\\ YY67B:,%,.G10 PRINT `HELLO`\| |\| A B }ASIC instruction.\The line number.   h h6.Z7THE REM INSTRUCTION\\Most instructions tell the computer t }o do something, but not . AA67B:,%,./The instruction is just a to anyone ii67B:,%,.Wreading a pr }ogram.\_3\10 REM This program was written\20 REM on 10/12/84 by Mary Jones.mm67B:,%,.[_0\\REM instructions are not exe }cuted by BASIC; it just passes over them. All programs shoII67B:,%,.7uld have some instructions to explain what t }hey do.   i i6.[4THE END AND STOP INSTRUCTIONS\\The and instructions stop a program.\\They don't  }mm67B:,%,.[have much other effect but they do let you know that the program will stop when it gets to ii67B:,%,.W }them.\\The difference between the two is that will print the line number that the NN67B:,%,.;A,;A,;@9,l6.' \2mm6.c "} \| Lesson | | BASIC | | BDT |\  \Z A$67B:,%,.!6-?:#}:A$}(%@:,,9@ ? B$)& >:A(%@:7@<@,,,)$,A-@@#= " to move on or %} for helpA ^>-@@#> # for or for help 6- )"@:B,'6-&@)&} AP"@:F,' AP0"@:T,'&6-?:,0 A*"@:C,' 6-?:,* A'}>"@:?,)"@:/,6-+%A(46-?:,> A ( $'6-&gg%@A AA (}A0A@APA`ApBBBOO&@ BBBBB B0)}BPB`Z@(@@K:5)@@@L!A(Z6-&A(!@*}6-&@2$&;+ -; (ԭ0]6-?:<,06-F:A ,%F:A!,$AV+}>-@V%$@A(%Z ]$    *CAR) What is your choice?- 4 >:,@ARC >,}'@:=:,,  ' AH  $ 6-?:, A 6-?:,LYAR!-@-}@ I " to move on or for helpU6-@Y j j6.\We'll use BDT quite often in this lesson to d.}emonstrate BASIC instructions and techniques.\\[[67B:,%,.IWe will load an example BASIC program, go into BASIC and let/} you run the nn67B:,%,.\example using BDT.\\Before you use BDT, you should understand a normal .\\Assume you are 0}mm67B:,%,.[in BASIC with a program in memory. You would type and RETURN. To stop a program that D<67B:,%,.*1}is running, you would press the key.@ D  k k6.]In this chapter and the ones following, 3 different environme2}nts exist. They are this lesson mm67B:,%,.[, Atari BASIC, and BDT.\\If you could look into your computer's memory, it 3}would look like  67B:,%,.this:\\\ 67B:,%,. ll67B:,%,.Z\\Now you are in the lesson. We will switch you4} into BASIC, and you will activate BDT so  XP67B:,%,.>you can watch the BASIC program either from BASIC or from BDT.T 5}X k k6.]We will show you commands that let you switch from one environment to another.\\We will take OO67B:,%6},.=you through them, but this is how they look as an overview:\\??67B:,%,.->Š\8\8 7} |\67B:,%,.RR67B:,%,.@8|  | \8 \6 ԭ\\;367B:,%,.!We'l8}l show you this .7 ; f f6.X5GETTING INTO BASIC\\When we have an example program that we want you to 9}run with BDT, jj67B:,%,.Xthe message at the bottom of the screen will be:\\ for or for help\\gg:}67B:,%,.UWhen you press the we'll enter BASIC, load the example program and list it ((67B:,%,.on the ;} .\\67B:,%,.8067B:,%,.8| \8\6\\4 8 pe e6.WOnce we are in BASIC, you<}r part will be:\\_4(1) To enter BDT by holding down the jj67B:,%,.Xkey and then pressing the ATARI key ( on t=}he lower-right corner of the keyboard).\_0\67B:,%,.2267B:,%,. #| \#\!ԭ\\_4nn67B:,%,>}.\(2) To run your program in BDT one at a time by pressing Ӡ each time you want to exec-%67B:,%,.ute an instr?}uction.) - Xf f6.X5RETURNING TO THE LESSON\\When you have tepped thru to the end of the example program ldd67@}B:,%,.Ror have seen all you want to, you will exit back to this lesson by pressing Š.\\n??67B:,%,.->Š\8A}\8 |\p67B:,%,.vYY67B:,%,.G\Note: You must be in BDT to return to the lesson. This meaB}ns that if oo67B:,%,.]you are in BASIC looking at the you must first press - to enter BDT thenC}-%67B:,%,. press Š to .) - * *;;6.15LET'S TRY BDT\\You're now ready for your first +ll67B:,%,.D}Zuse of BDT. For this first time through don't worry about tepping the program. We just  +hh67B:,%,.Vwant to familiarE}ize you with getting in and out of BDT. Make a note of these steps:\\+jj67B:,%,.X_4(1) Hit the space bar. This will lF}oad the example and enter BASIC.\\0(2) From BASIC  +gg67B:,%,.Upress - to enter BDT.\\0(3) Look at the G} and familiarize yourself *+SS67B:,%,.Awith it.\\0(4) xit back to the lesson by pressing Š from BDT.4+  H}6-@  \+ f+ll6.b5YOU MADE IT!\\Did you examine the BDT screen? You should have noticed a couple of things. I}The p+ll67B:,%,.ZBDT screen has four separate .\\(1) The variable window\\(2) The statement window\\z+@@67B:,%J},..(3) The stack window\\(4) The command window\\+mm67B:,%,.[ack up if you didn't notice these windows and try to fiK}gure out where they are. Remember +6667B:,%,.$to press the space bar to enter BDT.+   + +kk6.a5THE VAL}RIABLE WINDOW\\The variable window is the large window at the top of the BDT screen just +nn67B:,%,.\below the title.\\M}It is divided into halves by a line down the center. On the left will be +9967B:,%,.'the names of the variables used iN}n the +ll67B:,%,.Zprogram. On the right will be the values those variables contain. As a program is being +ff67B:O},%,.Texecuted with BDT you can watch the values of variables change as statements affect +SS67B:,%,.Athem.\\This windP}ow also displays BDT help when you press the .+   $, .,nn6.d5THE STATEMENT WINDOW\\The statement window is Q}just below the variable window. It consists of two 8,gg67B:,%,.Ulines. The top line is the statement that was last exeR}cuted, the bottom line is the B,jj67B:,%,.Xstatement about to be executed.\\When you press Ӡ, the statement about to bS}e executed L,ff67B:,%,.Twill be executed, and will then move up to the just executed line. The about to be V,@@67B:,T}%,..executed line will display the next statement.`,   , ,ZZ6.P5THE STACK WINDOW\\This window is used to stU}udy more advanced BASIC programs.\\,<<67B:,%,.*We will examine this window more later on.,   , ,NN6.D5V}THE COMMAND WINDOW\\This is where commands to BDT are displayed. ,nn67B:,%,.\Normally the message\\'Enter command or pW}ress ? for help'\\ is displayed. However when you ,nn67B:,%,.\type a command the command name will appear in the windoX}w. For instance if you through-gg67B:,%,.U a program, the word will be momentarily displayed in this window Y}each time you  -67B:,%,. press Ӡ.-   P-H H6.:5LET'S USE BDT\\Now its time to run a program with BDT. Z}d-TT67B:,%,.BThis program has 6 lines numbered 10 through 60. After you enter n-hh67B:,%,.VBDT from BASIC with [}-, you'll need to tep 6 times to see the whole program. x-aa67B:,%,.ORemember to watch the as yo\}u're pressing Ӡ. Also watch the -nn67B:,%,.\ .\\For your convenience all example programs are listed i]}n Appendix I of the -kk67B:,%,.YUser's guide.\\REMINDER\| - Enter BDT from BASIC ^}|\-\\67B:,%,.J| Ӡ Step one instruction |\| Š Exit back to the lesson |\-6667B:,%,.$_}-  6-@ . .qq6.gDid you notice the statement\\340 LET WRONG=QUESTIONS-COR`}RECT ?\\The computer evaluated an .67B:,%,. and stored .jj67B:,%,.Xthe value in . a} can be as easy as 10-7 or as difficult as .ll67B:,%,.Z(10*2)/(30-26).\\Let's look at (10*2)/(30-26). The b}/ means divided by, the + means plus, /ii67B:,%,.Wthe - means minus and the * means multiplied by. Parentheses meanc} evaluate first.\\/GG67B:,%,.5So (10*2)/(30-26) is evaluated:_7\20/(30-26)\20/4\95/   2 2ee6.[Parenthed}ses inside parentheses are evaluated before anything else.\\Look at ((10+4)/7)-2_8\2hh67B:,%,.V(14/7)-2\2-2\0_0\\If youe} have a question about order of evaluation, use parentheses. 2GG67B:,%,.5Look at 4*7-8/4\\(4*7)-(8/4) ((4*7)-8)/4 (4*(f}7-8))/4\2ll67B:,%,.Z28-(8/4) (28-8)/4 (4*-1)/4\28-2 20/4 -4/4\26 5 -1\\22267Bg}:,%,. 2 .3   : :hh6.^By the way, is optional in these examples. We can wq} B'DOS SYSBg+AUTORUN SYSB?HEAD BKL 01 BOL 02 BOuL 03 BLL 04 BJL 05 BOOL 06 BE 01 BE 02 BE 03 BE 04 BE 05 BE 06 BE 07 BE 08 BE 09 BE 13 BE 14 BE 15 BE 16 BE 20 BE 21 BE 22 BE 23 rite_3\\10 LET A=76\0\or\\10 A=76_0\\:ii67B:,%,.WThey both the value 76 to the variable . The LET statement ir}s also called the :jj67B:,%,.X statement because it a value to a variable.\\We hope you're enjoying s}:QQ67B:,%,.?yourself so far. It's now time to move on to the next chapter.:   >$%@6-?:,$ At}D2:L.02OHEATOEXALINKPTKENPRINOURPRINSCHITKEGOBDBRANCINKEBDSCRCAAMDKEBab:1'@'LETOHEATOEXALINKPTKENPRINAOURPRINSCHITKEGOBASIGOBDBRANCINKEBDSCRCADKEBv} w} 6-@d'6-AuU6-AuR'6-x}AuHn(6-AuX;A,(6-@c6-A6-AP'6-A36-A%?6-APK6-AW6y}-Ac6-APP 6-6-A";@9,P6.'\\ A*67B:,z}%@,.'6-?::A(%@:,,9@ ? B$)& >:A(%@:7@<@|},,,)$,A-@@#= " to move on or for helpA ED-@@#@ % for ï o}}r for helpD ^>-@@#> # for or for help6- )"@:B,'6-&~}@) AP"@:F,' AP0"@:T,'&6-?:,0 A*"@:C,' 6-?:,}* AD"@:?,)"@:/,#6-@1%A(:6-?:,D A ( $'6-&@%@}A AApAqAABBBB B0B5B6B@BPB`}BZ@(@@K:5)@@@L!A(Z6-&A(!@6-&@2}$& +-+11 (ԭ0c6-?:<,06-F:A ,%F:A!},$AVD-@\%$@A(%` c$  ɛ%   */AR/ What is your choic}e?4#  >:, AR@# >'@:=:,,  ' AH  $"6-?:," }A 6-?:,LIAR!-@@ I " to move on or for helpV6-@ X ]}AA6.75THE GOTO STATEMENT\\So far, the programs you've seen bMM67B:,%,.;have executed from the lowest to the highest} line number. lZZ67B:,%,.HThe statement lets us the in which instructions are vhh67B:,%,.Vex}ecuted. Look at:_3\\10 A=7\20 GOTO 10_0\\First we will execute line 10. This will {ii67B:,%,.Wput a 7 into variable A}. Then we will execute line 20 which tells us to go back up to }ff67B:,%,.Tline 10. This will cause us to . We w}ill then execute line 10 and move 7 into ~HH67B:,%,.6variable A again and so on until we the program.   } [[6.QLets Look at another small program._3\\10 COUNT=0\20 COUNT=COUNT+1\30 GOTO 20_0\\ff67B:,%,.TThis progr}am also loops forever, but at least statement 20 accomplishes something. ee67B:,%,.SEach time we execute statement 20}, we will add 1 to the value in COUNT. This will JJ67B:,%,.8cause us to count forever or until we the program.}   @ Jmm6.cWe will watch this program run under BDT. Pay attention to the line numbers shown in the about to} Tgg67B:,%,.Ube executed line of the statement window. This will show you the effect of the GOTO XZZ67B:,%,.Hsta}tement in a visual way.\\After you have stepped through this program ^ll67B:,%,.Zenough to understand what it is doing }you should return to the lesson with the Š key as h..67B:,%,.this example will never end.  6-@ }(# 2#mm6.c5THE BDT TRACE COMMAND\\There are times when pressing the key can be tedious. In this case you <#OO67B}:,%,.=can the program by pressing the Ԡ key while in BDT. A#PP67B:,%,.>While you are tracing a program you c}an of the F#mm67B:,%,.[ by pressing a digit from thru where 0 is pause and 9 is full speed. } To stop P#HH67B:,%,.6a trace press any key but the number keys. You can't U#SS67B:,%,.Apress Š to exit to the l}esson until you've stopped the .\\#\\67B:,%,.JREMINDER\| Trace a program } |\#7767B:,%,.%| .. Vary the speed of a trace |\#6667B:,%,.$#  }6-@ ' 'aa6.WThe statement doesn't just loop. Look at:_3\\10 A=6\20 GOTO 40\30 A=12\40 END_0\\$'Y}Y67B:,%,.GStatement 10 will move 6 into variable A. Statement 20 will to .'gg67B:,%,.Ustatement 40, skipping} statement 30. Statement 40 will end the program. This means 8'aa67B:,%,.Othat statement 30 will never be executed.\\L}et's enter BDT and tep through it.j'  6-@ t' ~'ii6._Now it's time to see if you understand the GOT}O statement. We will show you a small program. 'ff67B:,%,.TAssume the program was RUN. Choose the number of the stat}ement which is correct.\\\'67B:,%,.'YY67B:,%,.G10 A=7\20 GOTO 40\30 A=23\40 END\\ A will equal 23\ A will e}qual 7\'$$67B:,%,. A will equal 30' 6-@ ' 6.'WW67B:,%,.E10 D=4\20 GOTO 50\30 D=7\40 END\}\ D will equal 4\ D will equal 7\'ii67B:,%,.W_3 This program is incorrect because statement 20 GOTO'S line 50 whi}ch doesn't exist.' 6-@  ( 6.(XX67B:,%,.F10 A=7\20 GOTO 40\30 GOTO 50\40 END\50 A=14\60 END\\ A w}ill equal 7\(7767B:,%,.% A will equal 14\ A will equal 21(( 6-@ <( 6.F(YY67B:,%,.G10 A=0\2}0 A=A+1\30 GOTO 20\40 END\\ A will equal 1\ A will equal 0\P(ZZ67B:,%,.H_3 This program will loop forever, so the }value of A is indeterminant.Z( 6-@ ( 7@<@7,  * +mm6.c5USING BDT WITH YOUR PROG}RAMS\\So far when we've gone into BASIC/BDT loaded the program for  +hh67B:,%,.V to run. However, one of the b}est things about BDT is that it can be used to work +ll67B:,%,.Zon programs write.\\When we plan to go into BASIC/B}DT, the message at the bottom will +??67B:,%,.-read\\ for ï or for help\\+XX67B:,%,.FHowever, }before we let you use BDT on your programs, we need to teach  +6667B:,%,.$you how to enter and edit a program.R+   }. .pp6.f3ENTERING AND EDITING A PROGRAM\\There are several things you need to be able to do.\\First you need .aa}67B:,%,.Oto be able to . You do this by typing in the line number, .kk67B:,%,.Ythe BASIC state}ment(s), and .\\If the computer finds a error in what you typed in, /hh67B:,%,.Vit will display the line with }ҭ after the line number. To correct the line, you /ii67B:,%,.Wwould figure out what was wrong and type in the revise}d line with the same line number.:/   2 2oo6.eThe second thing you need to be able to do is . Th}is is done by typing the line number 2kk67B:,%,.Yof the line to be deleted, and .\\The third thing you need to be} able to do is 2dd67B:,%,.R using the command. This command has three formats:\_3\(1) LIST\2gg6}7B:,%,.U(2) LIST 320\(3) LIST 100,200\_0\The first would list the entire program, the second 2VV67B:,%,.Dwould list} line 320, and the third would list lines from 100 to 200."3   4` `6.RThe last thing you have to be able to do i}s clear a program.\\The command you use 4ll67B:,%,.Zis . This command deletes any program that is in memory. This }is useful any time you 4::67B:,%,.(need to start over with a `clean slate`.4    5i i6.[9ERRORS\\All the p}rograms you've run have run correctly. However, when you start writing *5kk67B:,%,.Yyour own programs, you may encounte}r errors when you run them. If an error happens, the 45ii67B:,%,.Wsystem will leave you in BASIC with an error message }on the screen. Look up the error >5ll67B:,%,.Znumber in your BASIC manual, then go back into BDT and step slowly to the} point where the H5[[67B:,%,.Ierror occured. You should be able to solve any error if you are careful.R5   6 }6kk6.aNow you'll enter a simple program to get used to entering and editing. Follow these six steps. 6TT67B:,%,.}BYou may want to write a note to yourself to help you remember.\_5\6ee67B:,%,.S0(1) Press the space bar to enter BASI}C.\0(2) Type in the following two lines:\6aa67B:,%,.O810 A=7\820 B=A\0(3) LIST it a few times.\0(4) Enter BDT w}ith ԭ.\6VV67B:,%,.D0(5) Step through the program.\0(6) Exit back to the lesson.\_0\6ll67B:,%,.ZNote: } ԭ will return you to the lesson if you haven't entered any program lines. 7  6- : :qq6}.g9THE BDT COMMAND\\Did you type in a program? If you didn't, ԭ would have returned you to :nn67B:,%,.\t}he lesson without going into BDT. If this happened, back up and try again.\\There is anoth:ll67B:,%,.Zer BDT command t}hat you will need to know. This is the key which is how you get back :kk67B:,%,.Yinto BASIC from BDT. Don't confu}se this with Š which you use to return to the lesson.\:mm67B:,%,.[%\#\# |\  }\| Lesson | | BASIC | | BDT |\:2267B:,%,.   :   >f f6.XYou might }want to back up and try out the command.\\When you're in BDT, you can hit >\\67B:,%,.Jthe or and it will show y}ou the BDT commands we have discussed here.\\>OO67B:,%,.=If you think you're ready, let's move on to the next chapter.}>    N %6-?:, AD2:L.03CHITKEGOBASIGOBDBRANCINKEBDSCRCADKEB8cdL% &LETOHEATOEXALINKPTKENPRINOURPRINSCHITKEGOBASIGOBDBRANCINKEBDSCRCADAKEB} } 6-@d36-AuU}6-AuR'6-AuH36-AuXu6-A6-AP'6-A36-A%?6-APK6-AW6-Ac}6-APi6-u6-Ak;@9,;A,'6-36-@a6.'\\}k A$67B:,%,.!6-?::A(%@:,,9@ ? B$)& >:A(%@:7@<@,,,)$,A-@}@#= " to move on or for helpA ED-@@#@ % for ï or for helpD ^}>-@@#> # for or for help 6- )"@:B,'6-&@) AP"@}:F,' AP*"@:T,' 6-?:,* A*"@:C,' 6-?:,* A>"@:?,)"@:/,}6-+%A(46-?:,> A ( $'6-&%@A ABBBB }B0B@BPB`BpBBBBBZ@(@@K:5)}@@@L!A(Z6-&A(!@6-&@2$& + -+11 (}ԭ0]6-?:<,06-F:A ,%F:A!,$AV>-@V%$@A(%Z ]$  ɛ% }  */AR/ What is your choice?4#  >:, AR@# >'@:=:,,  ' A}H  $ 6-?:, A 6-?:,LIAR!-@@ I " to move on} or for helpV 6- ) )kk6.a5THE PRINT STATEMENT\\Pretend for a minute that you don't have BDT. If you wan}ted to know what )hh67B:,%,.Vvalue a variable had you would have a problem. However BASIC has an instruction that ")h}h67B:,%,.Vallows us to see the value of a variable. This is the statement. For example, ,)dd67B:,%,.Rif we r}an this program:\\310 A=7\320 PRINT A\\we would see a 7 displayed on the 6)67B:,%,. .^)   h) }r)ff6.\5THE PRINT STATEMENT AND BDT\\If you are tepping a program in BDT and you execute a |)ee67B:,%,.Sstatem}ent, you won't see anything displayed on the . This is because it )__67B:,%,.Mwill be printed on the } which you aren't looking at.\\To see the )NN67B:,%,.< press the yellow key. To return to the })ff67B:,%,.T press again. Because you never left BDT, you can execute any BDT )LE67B:,%,.3comma}nd regardless which screen you're looking at.\I L )Y- %  Y '| Lesson | | BASIC |}----| BDT |)-- % ) * +NN6.DThe statement can do more than ju}st print a single variable.  +>>67B:,%,.,Assume we've executed the following lines._3+aa67B:,%,.O\\10 A=100\20 B=}1000\30 C=-33_0\\Hit any key to simulate each of the following  +ll67B:,%,.Z statements and observe the many differ}ent ways that the PRINT statement can work.\\\R+(6-A6-A(6-6@3\+ f+   40 PRINT A  p+}%  50 PRINT A,B,C % u+NN F*** 堬 z+%  60} PRINT A+B+C % %%+I& *** 䮠I  +P :  70 PRINT >:@4}, THE ANSWER IS>:@4,> P  THE ANSWER IS+QQ I*** 堠 }+_ C  80 PRINT >:@4, THE ANSWER IS>:@4,,A+B+CG _  THE ANSWER IS%%+A 4  90 PRINT >}:@4,A=>:@4,,A8 A A=+B 5  100 PRINT >:@4,A=>:@4,;A9 B A=+MJ B*** } 堧宠M . . .JJ6.@Now it's time to see some statemen}ts in action with BDT.\\/WW67B:,%,.Etep through the following example in BDT. After several statements /II67B:,%},.7press to see the output on the and /KK67B:,%,.9then again to return to the BDT screen.\\You can} use the /aa67B:,%,.O, , or any other BDT command regardless which screen you're looking at.\\&/kk67B:,%,.YN}ote: When a PRINT statement outputs something to the BASIC screen while you are in BDT, 0/OO67B:,%,.=the screen will fli}cker to indicate that output has occurred.D/  6-@ 2 2!!6.5THE INPUT STATEMENT\\2ff67B:,%,.}TSo far, our programs have calculated using statements, looped using 2RR67B:,%,.@statements, output us}ing statements and even reminded you 2``67B:,%,.Nwith statements. Now we'll show you how to communicate with} your program 2ZZ67B:,%,.Husing the statement.\\310 INPUT GRADE\\tells BASIC to ask you to 2bb67B:,%,.Ptyp}e in a value which BASIC will store in the variable named . A question 3ii67B:,%,.W mark, '?', will appear on the} along with a white box called the . 3VV67B:,%,.DThe '?' tells you that your program wants you to t}ype in some input.,3   6 6mm6.cIn this case you would type the number that you want to be assigned to the vari}able and then 6GG67B:,%,.5press to send what you type to the computer.\\6kk67B:,%,.YUntil you hit } your program see what you have typed. You can change your 6TT67B:,%,.Bmind and delete characters using t}he ˠ key or type in more.\\6<<67B:,%,.*Try typing a number now:\(remember ) 7   7)AR BAP})AR(7) You just typed   ) BBF7+! + BAx7 B'h : }:;;6.15THE INPUT STATEMENT AND BDT\\When you use BDT, :gg67B:,%,.Uexecuting an statement will flip you from} the to the . :>>67B:,%,.,Pressing will flip you back to BDT.\\:jj67B:,%,.XNote: I}f you input a letter when the program is expecting a number, you'll get an error :PP67B:,%,.>and go back into BASIC. J}ust press ԭ to start over.\\:AA67B:,%,./Now let's test some statements under BDT.:  6-@} > >ee6.[Did you see what's missing?\\All you saw on the BASIC screen was the question mark and the >kk67B:,%},.Ycursor (?). You were not told what to type in or how it would be used by the program.\\>ff67B:,%,.TThis is where }the statement helps.\\tep through the following program in BDT.>  6-@ hB rBii6._The next sa}mple program converts Fahrenheit to Celsius.\\Run it from BDT and watch it. Notice |Bkk67B:,%,.Ythat line 60 is a }to the beginning of the program so that it will execute again and Bii67B:,%,.Wagain.\\To exit, press Š. You can't pr}ess Š during an INPUT statement because the Bkk67B:,%,.YINPUT statement will get the Š, not BDT. If you make a mis}take in an INPUT statement, Bgg67B:,%,.Uyou will get an error and the program will stop. Just press ԭ and try }again.B  6-@ PF ZFhh6.^The last sample program of this chapter computes the growth of a bank accou}nt assuming annual dFhh67B:,%,.Vcompounding of interest.\\Even with the small number of statements that we've covered n}Fll67B:,%,.Zwe are able to write useful programs.\\In BDT use to execute until you are in the loop, xFQQ67B:,%,.?s}tatements 100-140. Then use to start it moving on it's own.F  6-@ 8Ji i6.[Now it's time to try a}nd write your own programs.\\You should enter ï like you did BJ3367B:,%,.!at the end of the last chapter.\\VJjj}67B:,%,.XYour program should input two numbers and put them in variables A and B. Calculate the `Jhh67B:,%,.Vaverag}e and store it in variable C. Print out the average.\\The Users Guide provides jJEE67B:,%,.3suggested solutions to the }problems in Appendix II.J  6-  N[ [6.MLet's try to write one more program. This program should do the f }ollowing:\\*Nhh67B:,%,.VInput your age and store it in a variable called YEARS. Calculate your age in months 4Ngg67B: },%,.U(YEARS*12), and store it in a variable called MONTH. Print out your age in months.\\zN  6- Rd d6 }.V9MODIFYING PROGRAMS\\Now you're ready to experiment with another powerful feature of Rnn67B:,%,.\computers.\\Try re }viewing example programs, but this time modify them by adding or changing Rkk67B:,%,.Ylines to better understand how th }ey operate.\\For example, you can add lines which print &Rjj67B:,%,.Xout variables or substitute your own variables in p}lace of the ones you've been given.\\0Rmm67B:,%,.[Most programmers like to modify existing programs to meet their unique} needs. It's easier :R--67B:,%,.than starting from scratch.bR   Hq %6-?:, AD2:L.04{ab:$$LETOHEATOEXALINKPTKENPRINOURPRINSCHITKEGOBASIGOBDBRANCINKEBDSCRCADAKEB} } 6-@d36-AuU6-AuR'6-}AuH36-AuXu6-A6-AP'6-A36-A%?6-APK6-AW6-Ac6-APi6-u}6-Ak;@9,;A,'6-@36-a6.' \k A$67}B:,%,.!6-?::A(%@:,,3@ 9 <$)& >:A(%@:7@<@,,,)$,A-@@#= " to} move on or for helpA ED-@@#@ % for ï or for helpD ^>-@@#> #} for or for help6- )"@:B,'6-&@) AP"@:F,' AP}0"@:T,'&6-?:,0 A*"@:C,' 6-?:,* AD"@:?,)"@:/,#6-@1}%A(:6-?:,D A ( $'6-&gg%@A AA A0A@A@PA@p}A@AAApA77&@ ABBB BZ@(@@}K:5)@@@L!A(Z6-&A(!@6-&@2$& + -+11 (}ԭ0]6-?:<,06-F:A ,%F:A!,$AV>-@V%$@A(%Z ]$  }ɛ%   *)AR) What is your choice?4#  >:, AR@# >'@:=:,,  ' A}H  $ 6-?:, A 6-?:,LIAR!-@@ I " to move on } or for helpV 6-  EE6.;5THE IF...THEN STATEMENT\\Remember this example program?\\mm67B:,%,.[10 !}COUNT=0\20 COUNT=COUNT+1\30 GOTO 20\\We said that this program would keep adding one to 3367B:,%,.!COUNT until we stop"}ped it. What jj67B:,%,.Xwould we do if we wanted it to stop after COUNT equaled 10? We would use the Ʈ bb#}67B:,%,.Pstatement to whether COUNT had reached 10 by adding a line 25 as follows:\\ SS67B:,%,.A25 IF COUNT=10$} THEN END\\What this says is: COUNT is equal to **67B:,%,.10 END the program.       gg6.]The %}Ʈ statement allows us to execute some instructions certain conditions are met. XX67B:,%,.F\\_3Look at:\10 IN&}PUT NUMBER\20 IF NUMBER=0 THEN STOP\30 REM CONTINUE  TT67B:,%,.BHERE\_0\In statement 20 ҽ is a . If th'}e condition dd67B:,%,.R is then the statement after the will be executed, and the program will  bb67B:,%(},.P. If the condition is then the statement following the will  67B:,%,. be executed.   )} dd6.ZUnless the statement after the instructs BASIC otherwise, the statement following an ``67B:,%,.N*}Ʈ will be executed next. For example, the sequence_3\\40 IF N=6 THEN 4467B:,%,."PRINT `HELLO`\50 PRINT `OUT T+}HERE`cc67B:,%,.Q_0\\will always print Ԡ. However it will also print if N=6. But, NN67B:,%,.7 which tests cc67B:,%,.Qwheth0}er A is greater than 7. Altogether there are 6 possibilities to test for:\\oo67B:,%,.]A=7 A equal to 7\A<>7 A 1}not equal to 7\A<7 A less than 7\A>7 A greater than 7\XX67B:,%,.FA<=7 A less than or equal to 7\A>=7 A g2}reater than or equal to 7    jj6.`In addition to the simple tests like A>=7, we can test for combinations 3}of conditions using the cc67B:,%,.Qoperators and . These work in a way that is consistent with their names. 4}kk67B:,%,.YFor instance, this expression:\\3(A>0) AND (A<11)\\would only be true if A were greater //67B:,%,.th5}an zero less than 11. ff67B:,%,.TSimilarly we would use to test if one the other of two conditions were tru6}e. oo67B:,%,.]For instance,\\3(A=3) or (A>=10)\\would be true if A were equal to 3 A were greater than !!67B:7},%,.or equal to 10.    oo6.eFinally there is one last operator to consider: This is . We can use 8}this with any condition to nn67B:,%,.\achieve the opposite effect of the condition. That is if we placed the oper9}ator before TT67B:,%,.Ba true expression then the result would be false. For instance:\\nn67B:,%,.\3NOT (A=7):}\\is true if it is true that A equals 7, or in other words if A is not equal \\67B:,%,.Jto 7. From this you shoul;}d see that\\NOT (A=7) is equivalent to (A<>7).\\    BB6.8Try the following quizzes on the Ʈ statem<}ent.\\\,67B:,%,.6ee67B:,%,.S10 A=7\20 IF A=7 THEN GOTO 40\30 A=23\40 END\\ A will equal 7\ A will equal 23\=}@$$67B:,%,. A will equal 40J 6-@ h 6.rgg67B:,%,.U10 A=7\20 A=A+1\30 IF A<14 THEN GOTO 20>}\40 END\\ A will equal 7\ A will equal 14\|XX67B:,%,.F_3 This program will never end as we will keep branching to?} line 20. 6-@  6.__67B:,%,.M10 A=3\20 IF A=3 THEN A=A-2\30 IF A=1 THEN A=44\40 IF A>42 THEN A=@}12\50 END\\II67B:,%,.7 A will equal 3\ A will equal 44\ A will equal 12 6-@  6.ff67BA}:,%,.T10 A=0\20 A=A+2\30 IF A>9 THEN GOTO 20\30 END\\ A will equal 2\ A will equal 10\ZZ67B:,%,.H_3 This examB}ple will never end because A will never be greater than 9.  6-  6.cc67B:,%,.Q10 INPUT A\20 IF A<44 TC}HEN GOTO 10\30 END\\ A will equal 44\ A will equal 43\pp67B:,%,.^_3 There is no way of knowing what A will equalD} as it must be input when the program is RUN. 6-@ 0 6.:jj67B:,%,.X10 A=7\20 B=3\30 IF NOT(A=7) OE}R B=3 THEN A=15\40 IF NOT(A=15 AND B=3) THEN A=45\50 END\\DII67B:,%,.7 A will equal 7\ A will equal 15\ A will eqF}ual 45N 6-@  7<@7,  X lii6._We will now enter and see some of these ƮG} statements in action.\\tep through the vll67B:,%,.Zfollowing sample program. Use the key to see how the IF...H}THEN statements control 3367B:,%,.!the printing on the BASIC screen.  6-@ @ T\\6.RBeforeI} we go on, a little something extra. BASIC allows you to put more than one ^hh67B:,%,.Vstatement on a line by separatiJ}ng them with a . For example:\\310 A=3:B=6:C=A+B\\hbb67B:,%,.PThis is useful with the Ʈ statement because K}it allows for more than one r]]67B:,%,.Kstatement to be executed if the is ._3\\10 IF N=6 THEN PRINT |=L}=67B:,%,.+`N EQUALS 6` :GOTO 100_0\\tep through the ZZ67B:,%,.Hfollowing program in BDT. This program calculatesM} change for a cashier.  6-@ (# <#``6.VThe next example will calculate your grade average. An ƮN} statement is used to F#ff67B:,%,.Tleave the that is accumulating your test scores when you enter -1\\Observe }[\&'LETOHEATOEXALINKPTKENPRINAOURPRINSCHITKEGOBASIGOBDBRANCINKEBDSCRKEB"P} "Q} 6-@dL6-AuU6-AuR'6-AuH36-AuX@;A"R},L6-@s6-A6-AP'6-A36-A%?6-APK6-AW6-Ac6-APi6-s A"S}*67B:,%@,.'6-?::A(%@:,,3@ 9 <$)& >:A(%@:7@<@,,,)$,A-@@#"U}= " to move on or for helpA ED-@@#@ % for ï or for helpD ^>-@"V}@#> # for or for help 6- )"@:B,'6-&@) AP"@:F,"W}' AP0"@:T,'&6-?:,0 A*"@:C,' 6-?:,* A>"@:?,)"@:/,"X}6-+%A(46-?:,> A ( $'6-&oo%@A AA A!A"A#"Y}A$A@APA`ApAGG&@ABB B0B@BPBB"Z}@K:#)(4!A(B6-&A(!@6-&@2$& + -+11 ("[}ԭ0]6-?:<,06-F:A ,%F:A!,$AV>-@V%$@A(%Z ]"\}$ 6-?:, A 6-?:,LIAR!-@@ I " to move on or for helpV "]}6-  pp6.f5THE FOR/NEXT STATEMENT\\BASIC provides a simpler way for us to count: the and statements."^} cc67B:,%,.QLook at:_3\\10 FOR NUMBER=1 TO 10\20 PRINT NUMBER\30 NEXT NUMBER_0\\Statement 10 ee67B:,%,.Stells "_}BASIC that we are going to loop and change NUMBER from 1 to 10. Statement 30 __67B:,%,.Mmarks the end of the loop.\\ "`}tep through this program in to see it work.*  6-@  4 >cc6.Y5THE STEP PARAMETER\\What if we w"a}anted to step by 2 instead of 1? There is an optional C1167B:,%,.part of the FOR statement, the Hii67B:,%,.W"b} parameter. For example, if we wanted to count from 0 to 10 by 2 we would use the Rmm67B:,%,.[following FOR statement"c}:\\10 FOR NUMBER=0 TO 10 STEP 2.\\The value can be any number, \__67B:,%,.Meven negative. For instance, the follo"d}wing would be a valid FOR statement:\\fmm67B:,%,.[10 FOR NUMBER=10 TO 0 STEP -1.\\The first time through the loop NUMBE"e}R would equal 10, the p==67B:,%,.+second time 9 and so on until it reached 0.    kk6.a;THE STACK\\Y"f}ou may have noticed while you were stepping the last example that some information ii67B:,%,.Wappeared in the stack wi"g}ndow of BDT. Before you can understand what BDT was trying to ff67B:,%,.Ttell you, you need to understand what a "h} is and how it is used by the computer.     oo6.eA is a way of storing information. The stack in a "i}computer can be compared to the device used  \\67B:,%,.Jin cafeterias to store plates. The device stores plates in a "j} where  nn67B:,%,.\only the top plate is available. When we put a plate on top of the stack ( in computer $ j"k}j67B:,%,.Xterms) all the other plates move down one position. When we get a plate off the top of . ``67B:,%,.Nthe s"l}tack ( in computer terms) the other plates all move up one position.\\8 gg67B:,%,.UThe difference between a computer'"m}s stack and a cafeteria's is that a computer stack B 0067B:,%,.holds information, not plates.V   `  j nn6."n}dIf you ack up and re-enter BDT with the FOR/NEXT example, you will see the following appear in the t DD67B:,%,.2stack"o} window when you execute the statement:\\~ __67B:,%,.MStack: Level=1 Top=FOR/NEXT from 10\\What BDT is telling you "p}is that\\_4(1)  ii67B:,%,.Wthe stack has one piece of information on it (Level=1) and\\0(2) the top of the stack  ll"q}67B:,%,.Zis recording the fact that a FOR/NEXT statement is in progress (Top=FOR/NEXT from 10).\_0\ XX67B:,%,.FAs w"r}e go through this chapter we will refer often to the stack window.    ]]6.SNow enter and watch this pr"s}ogram execute. It uses the and statements YY67B:,%,.Gto perform its looping._3\\10 FOR NUMBER1=1 TO 4\20 FOR"t} NUMBER2=1 TO 3 GG67B:,%,.5\30 COUNT=COUNT+1\40 NEXT NUMBER2\50 NEXT NUMBER1\_0\kk67B:,%,.YPay particular atten"u}tion to the stack window as you step. This program has one FOR loop mm67B:,%,.[within another. They are called "v} FOR loops. You should see the stack level go to 2 cc67B:,%,.Qat certain points in the program. Try to understand h"w}ow the stack is being used.h  6-@!  ff6.\This program contained a a .\\The "x} was from statements 10 through cc67B:,%,.Q50.\\The was from statements 20 through 40.\\Each time the"y} outer loop UU67B:,%,.Cexecuted, the inner loop executed 3 times. That is why the program hh67B:,%,.Vadded 1 to"z} COUNT 12 times.\\4 OUTER LOOPS * 3 INNER LOOPS=12\\If you don't understand \\67B:,%,.Jthese Ү , "{}back up and step through the example again.P   p aa6.WBy the way, a Ү loop can be used as a delay i"|}n your program.\\350 FOR I=1 TO __67B:,%,.M50:NEXT I\\will take about .1 seconds\\350 FOR I=1 TO 500:NEXT I\\will ta"}}ke nn67B:,%,.\about 1 second.\\\This can be useful whenever you have to a computer action such as ..67B:,"~}%,.a screen display or drawing.   X lqq6.g5THE ON...GOTO STATEMENT\\Now for another shortcut. Look at t"}he following segment of a BASIC program.vll67B:,%,.Z_3\\10 INPUT I\20 IF I=1 THEN GOTO 100\30 IF I=2 THEN GOTO 200\40 I"}F I=3 THEN GOTO 300\50 ee67B:,%,.SIF I=4 THEN GOTO 400_0\\Based on the value of the variable I we are going to branch"}aa67B:,%,.O to line 100 or 200 etc.\\We can perform the same function with ή_3\\108867B:,%,.& INPUT I\20"} ON I GOTO 100,200,300,400     @ Tdd6.ZThe ή works with I acting as a counter or into a list of"} statement numbers.\^YY67B:,%,.G\If I=1, then GOTO the 1st statement (in this case 100).\\If I=2, then h__67B:,%,."}MGOTO the 2nd statement (in this case 200). This follows for all statements.\\rhh67B:,%,.VHowever, if I<1 or I>[the nu"}mber of statement numbers] then no is executed. The |dd67B:,%,.Rstatement following the ή is the next one"} executed.\\Try the next example 4467B:,%,."in inputing different numbers.   6-@" (# <#jj6"}.`5THE GOSUB/RETURN STATEMENT\\So far every time we've executed a statement we've gone to a F#oo67B:,%,.]new are"}a of the program. If we came back we used another .\\\Using the and P#ll67B:,%,.Zstatements, a segment"} of a program can be used from many different locations. After each Z#oo67B:,%,.]use, a sends you back to the ne"}xt instruction after the .\\\You would want to do d#==67B:,%,.+this when you have a commonly used routine.#   "} ' $'ii6._For example, assume that we have a routine that averages two variables, A and B and prints the 8'FF67B:"},%,.4average._3\\1000 REM SUBROUTINE\1010 C=(A+B)/2\1020 B'jj67B:,%,.XPRINT `AVERAGE=`;C_0\\If we want to repeatedly a"}ccess this routine from a program which L'nn67B:,%,.\changes the values of A and B, we just add:\\31030 RETURN\\We can "}use the routine anytime V'jj67B:,%,.Xwe want by a GOSUB 1000 statement.\\Now enter BDT and watch how ® wor"}ks in `'##67B:,%,.the next program.'  6-@# . .ll6.bDid you notice the stack window while yo"}u were stepping the program? The GOSUB/RETURN statements .jj67B:,%,.Xshare the stack with the FOR/NEXT statements.\\Ev"}ery time a GOSUB statement is executed,.mm67B:,%,.[ the computer saves the next statement on the stack. When a return "}statement is executed, /ii67B:,%,.Wthe program branches to the statement on the top of the stack. After the statement "}is /cc67B:,%,.Qexecuted, it is 'ed off the stack and the statement below is now on the top.\\/::67B:,%,.(ack "}up if you like and watch the stack /BB67B:,%,.0as you tep over the GOSUB and RETURN statments.:/   2 2ll6"}.b5THE ON...GOSUB STATEMENT\\Similar to the ή there is an\ή®.\\The format 2jj67B:,%,.Xis:\\"}310 ON ABC GOSUB 100,200,300,400\\and somewhere after 100,200,300 and 400 there is2cc67B:,%,.Q a statement.\The"} return will be to the statement following the ή3   6 6qq6.gNow that you've gotten through MORE BRAN"}CHING, why not try writing one of these sample programs before 6mm67B:,%,.[continuing.\\\_4(1) Using a ү loop an"}d , print 10,9,8,7,6,5,4,3,2,1,0,BLAST OFF!6kk67B:,%,.Y\\0(2) Write a subroutine that will take NUMBER and set SQU"}ARE equal to NUMBER*NUMBER. 6kk67B:,%,.YIn a FOR/NEXT loop GOSUB this subroutine and print NUMBER and SQUARE for NUMBE"}R=1 to 100.4:  6- :f f6.XDid your program work? If you want to try again or write another, back u"}p.\\Otherwise, :;;67B:,%,.)it's time to move on to the next chapter.:   8J %6-?:, AD2"}:L.06\&'LETOHEATOEXALINKPTKENPRINAOURPRINSCHITKEGOBASIGOBDBRANCINKEBDSCRKEB ;QUESTIONCORRECWRONGRAD РӠ͠ӛ-@&}-@( -&2-'$A<ӠŧϠԛD2:E.01РӠ͠ӛ-@$M;JCOUN 6-6-%@ @ D2:E.02IONS-CORRECT50 LET GRADE=CORRECT/QUE(X ;J 6-@ @@6-@(D2:E.03IONS-CORRECT50 LET GRADE=CORRECT/QUE,X  ** "THE FOLLOWING IS A LIST OF NUMBERS6-6-%@( 2 ΠϠŠ2}àΛ< @0D2:E.04WING IS A LIST OF NUMBERS6-6-%@( 2 ΠϠŠ0( &HWGRADAGSCOR (2D2:E.05Λ60 GOTO 30ECT/QUE4e,MILEGALLONMILEAG $$ ENTER NUMBER OF MILES DRIVEN&& ENTER GALLONS OF :}GASOLINE USED(2 6-'< MILEAGE=FD2:E.06NUMBER OF MILES DRIVEN&& ENTER GALLONS OF 8G"FAHRENHEICELSIU "" INPUT DEGREES FAHRENHEIT:##-+&@2,$@'@ (>} 2..  DEGREES FAHRENHEIT IS  CELSIUS< @D2:E.07:##-+&@2,$@'@ (<O,BALANCINTERESYEA ++ "ENTER STARTING BALANCE IN DOLLARS:))  ENTER INTEB}REST RATE(.07 FOR 7%):(26-d Лn6-%@x6-$+@%,&& BALANCE AFTER YEAR B} IS  AD2:E.08 ++ "ENTER STARTING BALANCE IN DOLLARS:))  ENTER INTE@#"1 !!͠ԬӠŧϠԛD2:E.09+INTEREST)130 PRINT "BALANCE AFTER YEAR ";YEAR;" IS ";BALANCED?!0 6-@6-@6-@(   A IS LESS THAN B- J}ΠϠŠàΛ2# !# THIS SHOULDN'T HAPPEN<0 %"0  EXPRESSIONS CAN BE IN CONDITIONSF#"@# J}A IS EQUAL TO 1P$$ ONE IS CONSIDERED 'TRUE'D2:E.136-@(   A IS LESS THAN B- HD' COSPAICHANG ENTER COST OF PURCHASE:  AMOUNT PAID:(2/ N} % THAT'S NOT ENOUGH MONEY/ @< 6-&F'"  THANK YOU' @P YOUR CHANGE IS $ Z N} THANK YOUdD2:E.14 ENTER COST OF PURCHASE:  AMOUNT PAID:(2/ L 9+COUNTETOTAGRADAVERAG !! ENTER TEST SCORES (0-100) STOP BY ENTERIR}NG -16-(6-2  ENTER GRADE:<F"6@AP6-%@Z 6-%d @PR}n 6-'x YOUR AVERAGE IS: D2:E.15 !! ENTER TEST SCORES (0-100) STOP BY ENTERIP?0CHOICFAHRENHEICELSIU ++ #ENTER FOR FAHRENHEIT TO CELSIUS++ # OR FORV} CELSIUS TO FAHRENHEIT  OR TO STOP.(2 <"@AF"@AP"&V}Z Ġd @n"" INPUT DEGREES FAHRENHEIT:x##6-+&@2,$@'@  AV} ENTER DEGREES CELSIUS:!!6-$@ '@%@2, 6&&  FAHRENHEIT =  CELSIUS.@ JV} T @D2:E.16CELSIU ++ #ENTER FOR FAHRENHEIT TO CELSIUS++ # OR FORT:INUMBE -@@  (D2:E.20310 PRINT FAHRENHEIT;" FAHRENHEIT = ";XW,yNUMBERNUMBERCOUN -@@-@@6-%@(^} 2 D2:E.21ERCOUN -@@-@@6-%@(\   !! ENTER A NUMBER FROM 1-4:''AAAA(  OUT OF RANGE2b} @d  WENT TO 100n @  WENT TO 200 @,  WENT TO 3006 @  WENT TO 400b} @D2:E.22ENTER A NUMBER FROM 1-4:''AAAA(  OUT OF RANGE2` 6-@6-@0 An6-@!x6-@g Af}6-@06-@ ASUBROUTINE6-+%,'@ AVERAGE=$D2:E.f}23 6-@6-@0 An6-@!x6-@g AdthisP#1167B:,%,. as you tep through it in .#  6-@ ' $'cc6.YYou've seen that the Ʈ} statement can act as a -- a device to reject values.'2267B:,%,. it doesn't like.\\The Ʈ8'ff67B:,%},.T statement can also be used as a to direct the computer to process different ='((67B:,%,.sections of a progr}am B'\\67B:,%,.Jbased on a variable's value.\\Execute the following temperature conversionL'PP67B:,%,.> program whi}ch is an extension of the one in the last chapter.j'  6-@ *7 76.)Now write your own program. Pick }one of +ii67B:,%,.Wthe examples below, go into BASIC and try to write the program using BDT to help you.\\ +jj67B:,%},.X_4(1) Input a number and print it out only if it is greater than zero.\\0(2) Input two +mm67B:,%,.[numbers and pr}int out the smaller of the two.\\0(3) Print out the numbers 1-10 using GOTO  +67B:,%,. and a loop.R+  6-} .k k6.]Well, that's all for this chapter. If you want to try to write a different program, back up .oo67B:},%,.]and pick a different one.\\Writing programs and testing ideas is the fun part of programming.:/    N %}6-?:, AD:L.05KPTKENPRINOURPRINSCHITKEGOBASIGOBDBRANCINKEBDSCRCADAKEB