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ȾɾM$ mHݓǾ phϾ A ԟ ` ])Y 񩢍`Ⱦɾ0Ǿ p)莼 * 6 w= l& l8Hh l` 6Y׾ؾ+پھ p|پɾʾ`HV)jh츾$-ˌھپLp k V)@W0!XY aX6Y7` a YX`X:Y;τ<:: <`:8`'OV)Jj *f a  ԟ  ԟ ⟭ + +:ji  ԟɃ B , ԩ p`SW)0پȾھɾ p p 3LjÍ L I 9 1׾ؾ  p p 3 H h(`׾ؾ`  ߭׾t8퍼mؾŰ펼t폼 L8` `F`4W)ɐ/XYjV) *8` h e`l׾ XYW0V):W׾ؾ_`)0%I0)3]8X^YȰ8` 8` p Ⱦɾʾ8`پھW)@%ZȾ pSɐ"jÍgh I @8gȾhɾʾg׾hؾ  p hgͺ칾`L3V)jC mMjà Lp `VJJ°LyLp *)< LA * LAW)8VJưϥ3 ⟢BT eօ ܬ L s򩣍S3 Ly B# e $L? L Y kimljn`  pg׾mȾXhؾmɾYtѮȾɾ YX`8gM CgIY2m*b6>BSAVERIFYBLOADELETECATALOGOPENWRITEXECREATEFRES`[ ~LFLnyz:'ȱuȱve湩 `hhL?@ABCDEFGHIJTEP UN ONTINUE RACE (SPEED -)AGE OTO APE ARIABLE SELECTIONNITIALIZE REAKPOINT SELECTION-RESTORE A VARIABLE BREAKPOINT.UP/DOWN ARROWS(//E) OR (II+)-MOVE THEL~MECA BASIC DESIGN TOOL>ENTER COMMAND OR PRESS ? FOR HELPSTACK: LEVEL= TOP= >STEPFOR/NEXT FROM GOSUB FROM LINE# BP:>BREAKPOINTLINE NUMBERVARIABLE>GO TO >TRACE (SPEED=) REMEMBER, PRESS CTRL-B TO ENTER BDT 79% <" "+ A3 F10L P(4);"BLOAD PREBDT"` U115,0:116,118v Z(4);"BLOAD BDT" d768 n31232  **********************; * 13-JAN-84 *X **********************^ h3:9n" "#9(" BASIC DESIGN TOOL "*9," "-92" COPYRIGHT 1983 MECA " L5LLL"L  KN)_ `@S8` ԠŬLL<[B?I>孓`仫6VtCicQĿUKqtVt Nʮq$6,⨁ K6, VtI=v!gNVt Vt  lg~TŠӠŠҠüϠž(+@ABCDEFGHIKLMNPSV     T[fouu~ՠٯ* PWN*]ĿNTz @n6VC/+A>@I5gN Oz @n[Dz @nd0,~z @`$仫@v$⩔,CTORENAMEBRUNLOCKCHAIN#FLUSHREADPOSITIONOMONPR#PREFIXCLOSEAPPENDx{[{0ǭ0hЫ}wA Xw­孶׭fl@@ -!S    !C- !ABELSDFRV@@ !$(19@E;{3{D0}1/23 } {zLH | }h _H | |hɎ 1{i LwH1{hɂ`l8 e A L< v zy{v{u \ J{{ { t    z " I V1{0 *L - eL  L e))`'(`  `H@Hzh z8zMz,z0)?(`zL'=zL'  `8{9{:{L8ߍ9}:d{e{f {Lde}f\_~` { ~ U؍{z " L L ؈${ ()$0  ;${ ${0 )zȱ)z. ^ y 4 ȱ m${` Ȍ'{ '{ m${`z ʎ ń,+{0,,{0`zhhhh UL M${H,{${ %${ ${Б` ؈8`zz [ A :0`8` Ȍz`${H${ ${h${` $${${  L5${ ${ k $${  ${ ȩ({ ̐ ,ɕLɈɍ ؈L({zȩ ; ( m${ L)${` 0 z LLA 07  0,% ȱ 0L"{$( HhLČ 0U:Q0,)E 0>:,8"{$1 0,*:&1" z#{ '{zL"{"{ȑ${${L${ (`${  (` $${${ 0L $${${ 0L${z'${ ${ z${ ۊ LI${z! ${ ${ ۊz${ 0 LIz${ $0 ~~@H~~~~~H~XXlX|XވL${ ۊ${${`  ` $${+ e "  LI,,` |nX~|nX~|~HXv~~|nX|v~~|np~|lPv~~|d@Pvv~|dP~zL'H2z2h8 4 檠^ [ IL-z2`   Lu{v{{{` L"zLLz+z! {(! {{ TP`zz {!{ {T{P`0`  B{ 'Ș1:,z0!,z0z :L2" ,z0zz :L{!` H2z2h [z2(${!hh` L $uvL  ${{L ezzQɁɰ $zL "$ziȹ zzȾiiz $zL lzL{z$z% {  }L8h{h{z$z% Q~{H{H J { L~$z%z` I a uL E { { p {{ ` Y`{{{{ {{`zzȥ!{)! 8:ɲz8Єτ ,0 8 ,0 : : 8L .{ +{+{$ $($ N.{/{Ъ` V/{ Ȅ$  $($ /{`/{ 2{ʝ2{ (/{`.{/{ 2{ .{-+{(*( ؈N.{/{` 2{ȹ2{` 芨2{` L瀭{8{9{:{d{e {f _؍`z 4L  ؈Lmzz "{2{#{2{z(Ȍz$  4 z(L #{"{ ؈z$LA "{2{2{`H ȩ(h` `/{i` >{2{`.{ʎ/{+{ 2{Dʽ2{>=< > = z${H${ m${zh${`${ (i)i  L$`ȱ LL钥jiklLiȥiL钥iiLwhole number. So if INT(17.5)=17 then 3*INT(17.5)=51The SQR FunctionA function can be used in an expression wherever a constant or a variable name can appear. As an example, the function SQR calculates the square root of any positive number:10 A=SQR(9)assigns 3 to A.10 A=SQR(9)*2assigns 6 to A.Now we'll enter BDT and observe SQR in action.H1NUMBSROOTThe RND FunctionA commonly used function is RND.10 X=RND(1)stores a random number between 0 and 1 in X. The 1 in mandThere is one last function to look at, PEEK and an associated command, POKE. PEEK lets you look into your computer's memory one byte (a byte is the smallest unit of computer memory) at a time. POKE lets you change bytes in memory.To use PA better way would be to use the DEF FN command. This allows you to create your own function that you can use just like the built in functions.Let's go into BDT and watch an example which uses DEF FN.H4PIIThe PEEK Function and the POKE Com=1/COS(X)ARCSIN(X)=ATN(X/SQR(-X*X+1))etc.The DEF FN CommandThere are several ways you could use derived functions. You could set up a subroutine that would calculate SECANT given X, and GOSUB the subroutine whenever you needed the secant of X. radians of expression.Derived FunctionsDid you notice there was no secant function?For this and other functions that aren't built in, you have to calculate the values using the built in functions and the math operators.For example,SECANT(X)OS COS(expression) returns the cosine of expression. Expression is assumed to be in radians.TAN TAN(expression) returns the tangent of expression. Expression is assumed to be in radians.ATN ATN(expression) returns the arctangent inl logarithm of expression.LOG(1) equals 0LOG(20.0855369) equals 3Trigonometric FunctionsThere are also some trigonometric functions in BASIC.#SIN SIN(expression) returns the sine of expression. Expression is assumed to be in radians.Cthe cursor on the screen. The 0 is a dummy argument like in the RND function.EXP EXP(expression) returns e (2.718289) raised to the power expression.EXP(1) equals 2.71828183EXP(3) equals 20.0855369LOG LOG(expression) returns the natura(3) equals 3ABS(-3) equals 3SGN SGN(expression) returns-1 if expression is less than 0,0 if expression is equal to 0 or1 if expression is greater than 0.#POS POS(0) returns a number from 0 to 39 indicating the horizontal position of red loops as PI is calculated.H3NUMDENXYPIMore FunctionsNow we'll quickly run through some additional functions.#ABS ABS(expression) returns the absolute value of expression. That is the value of the expression with its sign removed.ABSpoint, 1 is added to DEN. If a point is less than 1 unit from the origin (inside the circle) 1 is added to NUM.The area of the square is 4 while the area of the circle is PI. Thus NUM/DEN=PI/4 or PI=4*NUM/DEN.Enter BDT and Trace to watch several hundvalue of PI get closer and closer to its true value.A Description of Monte Carlo PIAssume a 2*2 square containing a circle with a radius equal to 1. The program generates random points in the square centered on the origin of the X, Y axis. For each the INT, SQR, and RND functions. This is the Monte Carlo method.This is one of the few example programs that involves complicated math, so if you aren't a math buff, don't worry. Just skip over it and run the example program in BDT. Watch the lowing example uses INT and RND to simulate the toss of a die by generating a number between 1 and 6.H2RDIEThe next example is something special. It's also somewhat mathematical and complicated. It derives the value of PI (3.14159...) by usingRND(1) is a "dummy" argument. It must be used, but RND(1) will always return a different number between 0 and 1.Note: INT(RND(1)) will always return 0, because RND(1) is always less than 1.A common use of RND is to generate random integers. The folEEK and POKE effectively, you need to understand exactly where information is stored in the computer. There is a program demonstrating POKE in the Paddles and Sound chapter.The CALL CommandLet's look at one last command, CALL. This command is included in Functions because it doesn't really belong anywhere else.CALL lets BASIC link to a machine language subroutine.For example,10 CALL -198would CALL a routine that beeps the speaker. The CALL command is also demonstrated in the Pother number if it is numerically less. In the case of strings, one string is less than another if it comes before the other alphabetically.The computer compares strings from left to right, one character at a time. It stops as soon as one character is lariables. You can:Assign to them:10 A$="HELLO THERE"READ into them:10 DATA HELLO THERE20 READ A$INPUT into them:10 INPUT A$Compare them:10 IF A$<"HELLO" THEN GOTO 100When we compare numbers, one number is less than anin the variable "A$". A string variable's name must end with a $ . The string must be enclosed in quotation marks. The quotation marks tell BASIC where the string starts and where it ends.String variables are used in a fashion similar to numeric v\^_`abcdefgcan contain any characters you choose, such as ABC123!@#$, etc.String VariablesStrings become useful when using string variables. A string variable holds a character value. For example:10 A$="HELLO THERE"would store the string HELLO THERE StringsLEN LEFT$ RIGHT$ MID$ Concatenation(+)STR$ VAL CHR$ ASC DIMIn this chapter we'll teach you how to use character strings.You've already seen strings used. In10 PRINT "HELLO THERE"HELLO THERE is a string constant.Strings  "ENTER NUMBERS TO"8 "FIND THEIR SQUARE ROOTS"V "ENTER NEGATIVE TO STOP"` (NUMBn 2NUMB0Ā <SROOT(NUMB) F"THE SQUARE ROOT OF ";NUMB;" IS ";SROOT P40integers.Well you can probably function pretty well on a computer now! If you need more practice, backup and write another program.If you're ready, let's move on to the next chapter. the square root (SQR), the sine (SIN), and any other functions you care to of the numbers 1-100.(2)Using DEF FN, INT and RND, create a function that will generate a random integer between 1 and 20. In a FOR/NEXT loop, print out 10 of these random e machine while experimenting with them, but you may have to restart the computer if the system stops working normally.Well that's pretty much it for functions. Why not try using them in these suggested programs:(1)In a FOR/NEXT loop, print outaddles and Sound chapter.Be careful when using PEEK, POKE and CALL.These commands can alter the contents of any memory location in the computer. This can lead to problems if they are executed without knowledge of what they do.You can't hurt thess than or greater than the other.The computer recognizes the letters of the alphabet because each letter has a distinct numeric code called ASCII (pronounced AS-KEY). An example program demonstrating these codes appears later in the chapter.The LEN String FunctionA string can store from 0 to 255 characters. If you attempt to create a string longer than 255 characters, BASIC will give you a STRING TOO LONG error.The LENgth function returns the number of characters in a string. For example ion several times.Try rewriting some examples to better understand how strings work.d.(2) READ in a string and print out how many A's, B's, C's, etc. it has.(3) Modify the bubble sort program from the Arrays chapter to work for an array of strings.This completes the chapter on strings. You may want to review this sectits secrets.I5W$(0)W$(1)W$(2)W$(3)W$(4)W$(5)W$(6)W$(7)W$(8)ISECRET$T$MISSESG$SWITCHQ$Well, that's how strings work. To be sure you understand strings, try writing the following programs:(1) Input a string and print it out reverseString arrays can be sorted like numeric arrays.Let's go into BASIC and run a program that uses string arrays. This plays a game of hangman. Run it several times by typing RUN and RETURN. When you understand what it does, go into BDT and discover iric arrays, there are string arrays. String arrays are dimensioned using the DIM command. The following:10 DIM A$(10)would create a string array with 11 elements, 0 thru 10. String arrays are very useful for storing lists or tables of names. of a string expression and returns its ASCII code.ASC("A") returns 65ASC("!@#") returns 33CHR$ and ASC are opposites.Let's go into BDT and examine a program that uses these string functions.I4AS$BIC$CODEString ArraysJust like numeto ABC.STR$ and VAL are opposites.CHR$ CHR$(arithmetic expression)takes an arithmetic expression as an ASCII code and returns the character the code represents.CHR$(65) returns "A"ASC ASC(string expression)takes the first charactermetic expression)takes an arithmetic expression and returns a string.10 A$=STR$(7+6+5+4)assigns a string, "22", to A$.VAL VAL(string expression)takes a string expression and returns its numerical value.20 A$="500"30 ABC=VAL(A$)/2assigns 250 10 ST$="HELLO THERE"20 TEMP$=LEFT$(ST$,5) + " YOU " + RIGHT$(ST$,5)30 PRINT TEMP$would display HELLO YOU THERE on the screen.Let's go into BDT and see string concatenation in action.I3S$S1$S2$S3$More String FunctionsSTR$ STR$(arithon the screen.Let's go into BDT and see substring functions in action.I2A$B$C$D$E$Concatenating StringsThere is one string operator, + . The + operator is used to concatenate (splice together) strings. For instance the following:indicated number of positions. If the number of positions to include is not defined, MID$ will continue to the end of the string. For example:10 ST$="HELLO THERE"20 PRINT MID$(ST$,4,5)30 PRINT MID$(ST$,3)would display LO TH and LLO THERE T$ and RIGHT$ function.10 ST$="HELLO THERE"20 PRINT LEFT$(ST$,3)30 PRINT RIGHT$(ST$,4)This program would display HEL and HERE on the screen.MID$ returns a substring begining at a specified position in the string and continuing for an we can use to reference a substring: LEFT$, RIGHT$ and MID$.LEFT$ returns a specified number of characters starting at the beginning of the string. RIGHT$ does the opposite. The following example displays the format used for specifing a LEFf we ran the following program:10 ST$="MECA"20 PRINT LEN(ST$)we would see 4 displayed on the screen. Let's go into BDT and see a simple use of LEN.I1S$LSubstring FunctionsA substring is a part of a string. There are three functions  R(1)DIE1(R6)&DIE.(10 c and requires POKEing a small routine into memory and then CALLing it.Let's go into BDT and run a small program that makes sound by printing the CHR$(7) character.J3IBASIC SoundThe theory behind all sound production on the Apple is the abilitrst is the BELL character. Any time you PRINT a CHR$(7) or a CTRL-G, the Apple will beep.The second technique is also available directly from BASIC using POKE and is really only usable for sound effects.The third uses machine language to play musi a function using DEF FN to make it easier to read a button.Note: If you skimmed the chapter on Functions you might want to review these particular functions.J2B0B1SoundThere are three techniques to produce sound on the Apple computer. The fiater than 127 indicates the button is being pressed. The values to PEEK are as follows:Button 0 = PEEK(-16287)Button 1 = PEEK(-16286)Button 2 = PEEK(-16285)Let's go into BASIC and watch a program that reads the buttons. Notice how we set upn 0 and button 1 are available from the keyboard as the Open Apple and the Closed Apple.There are no functions in BASIC for reading the buttons. You must use the PEEK function. To read the buttons you PEEK at a certain memory location. A value greDL(0) and PDL(1) repeatedly.J1P0P1The ButtonsMost paddles and joysticks have push buttons as part of the controller. Joysticks usually have two and paddles one. There are 3 buttons on the game I/O connector. If you have an Apple //e, buttoght.If you are using a joystick, it acts like two paddles in one. Movement in the horizontal direction is usually read with PDL(0). Movement in the vertical direction with PDL(1).Let's go into BDT and run a small program that reads the values of P port numbers, 0, 1, 2 and 3. The PDL function returns a number between 0 and 255 which indicates the position of the paddle controller at the time the instruction is executed. 0 is usually all the way to the left while 255 is all the way to the ri ignore the paddle and button example programs.Whether you have a joystick or a set of paddles, you use the same function to "read" them, PDL. PDL is used like any other function, for instance:10 PRINT PDL(1)20 X=PDL(0)/26+1There are 4 paddleiklmnopqrseveral techniques of sound generation.The PDL FunctionThe Apple computer comes with a Game I/O port in the back of the computer. A joystick or paddle can be plugged into this "port". If you have neither, you can still go through this chapter butPaddles and SoundPDL Buttons Sound Sound RoutineIn this chapter we will present some of the "fun" capabilities of the Apple computer. There are two areas that are covered in this chapter. The first is the paddles and buttons. The second is sy of the computer to "click" its speaker. Tones are just a series of clicks in rapid succession. Fairly interesting effects can be achieved by "clicking" the speaker in BASIC. The trouble is that BASIC can't "click" the speaker fast enough to play notes. To do this we must work in machine code as we'll soon see.The way we "click" the speaker is by PEEKing at a specific memory location, i.e.10 X=PEEK(-16336)Let's go into BDT and watch a program use this technique of producing sound.RUN the direction). The hi-res screen is 280 points wide in the X direction and 160 or 192 points high in the Y direction.The GR CommandIn this chapter we will look at the lo-res graphics mode. The first command we'll study is GR. When GR is executeuwxyz{|}~ution refers to the number of points that can be displayed on the screen. Lo-res has 16 colors while hi-res has 6. The lo-res screen is 40 points wide in the horizontal dimension (X direction) and 40 or 48 points tall in the vertical dimension (YLo-Res GraphicsGR COLOR PLOT VLIN HLIN SCRN TEXTThe Apple computer has two types of graphic modes. Low-Resolution (lo-res) and High-Resolution (hi-res). There are two ways in which these modes differ. Colors available and resolution. Resol  NUM0DEN0$X(1)213(Y(1)21A2DENDEN1]<(XXYY)1NUMNUM1nFPI4NUMDENvKPI~P30 d generation. A fairly good music program could be created using its techniques.ound routine out of the User's Manual.Well, that's all for Paddles and Sound. The paddles are the basis of many fine game programs, and of course sound is required in any good game.The last program we showed is the most powerful technique for sounyou turn the paddle.(2) Write a program that uses the two paddle values and passes them to the machine language sound routine as the pitch and duration values. Have it play the note when one of the buttons is pushed. You can copy the code for the s or more of the following programs.(1) Write a function using DEF FN that will take a paddle number and return a number between 1 and 10. Hint: You'll need to divide by 26 and add 1. Print the value of this function 100 times on the screen while it into memory. Next, POKE in the desired sound's pitch and duration. Then, CALL the routine to play the desired note.Slowly step through the following demonstration of this technique.J5ICPTime to write some of your own programs. Pick one Machine language on the other hand is more than fast enough. The actual mechanics of the routine you will use is beyond the scope of this lesson, however you should be able to copy it and make use of it. The first step in using this routine is to POKEprogram first because the timing is important.As you Step the program in BDT, listen carefully when the PEEK function is executed and you will hear the speaker click.J4SIXJMachine Language SoundBASIC is too slow to effectively play music.d, the computer will clear the text screen and create a lo-res graphics screen in its place. The top of the screen will be a 40 by 40 lo-res screen. At the bottom will be 4 lines of text. Normal PRINT commands will output in these 4 lines of text.If you wanted to use the whole screen for graphics, you would issue a POKE -16302,0 after the GR command.The COLOR CommandAfter a GR command, the default color is black or color number 0. If we want to put color on the screen, we need to tell de? The TEXT command. This resets the screen from whatever graphic mode the computer was in to the normal text screen. Go into BDT and step through a program that uses the TEXT command.K6Time to write your own program. Pick one of the followilp your understanding of the program's operation. RUN the program in BASIC first, then enter BDT to Step through it.K5YXCBVXVYBXBYThe TEXT CommandWell, you're almost done with graphics, but how do you reset the screen to the normal TEXT mo can be used. You must watch the program from BDT.K4CThe next sample program puts together all of the lo-res graphic commands we have learned so far. The program simulates a bouncing ball. Pay careful attention to the REM commands as these will heics. It is used to figure out the color of a certain point on the screen. For example:10 PRINT SCRN(12,15)would print the color (from 0 to 15) of the point at X=12, Y=15.Let's go into BDT and see a simple program that shows how the SCRN functionnds must be less than the second. For example:10 VLIN 30,14 AT 12would be illegal.Let's go into BDT and watch an example program that uses the HLIN and VLIN command.K3XYCX1Y1The SCRN FunctionThe SCRN function is used with lo-res graph.The VLIN CommandSimilar to the HLIN command is the VLIN command. This is used for drawing vertical lines. For example:10 VLIN 14,30 AT 12would draw a vertical line from Y=14 to Y=30 at X=12. The first parameter in the HLIN and VLIN commacommands that make our job easier. One is the HLIN command. A sample of this command would be:10 HLIN 10,20 AT 39which means draw a horizontal line from X=10 to X=20 at Y=39. Like PLOT this would use the present color as set by the COLOR command be set to black as BASIC won't do this for you.K2YXCThe HLIN CommandIn the last two examples when we wanted to set a horizontal line to a specific color, we used a series of PLOT commands typically from a FOR/NEXT loop. However, BASIC has some confines of the screen and PLOT a random point at that position.Note that this program uses the full screen 40 by 48 graphics. To do this the POKE discussed under the GR command must be executed first. Then the bottom 8 lines of the graphic screen must Then go into BDT to watch it. Remember to use the Page command from BDT.K1CXYAs another example of using these lo-res graphics commands, the following program will select a random color to draw in, then it will select a random point within theirst would put a point at the lower left hand corner of the screen, the second at the lower right hand corner, and the third 20 points from the left border and 14 points down from the top.Run the following program that draws bars in every available color.oint on the screen?Use the PLOT command. If we're drawing on the 40 by 40 screen, we can issue a PLOT command with an X and Y parameter between 0 and 39.These would all be valid PLOT commands:10 PLOT 0,3920 PLOT 39,3930 PLOT 20,14The fft manual. Or, if you have a color monitor the first example program will display the colors.The PLOT CommandNow that you know how to set the computer to graphic mode with the GR command, and to set a color with the COLOR command, how do you draw a pBASIC which color to use. The COLOR command is what we use.To set the color to 7, you would type COLOR=7. Colors can range from 0 to 15 where 0 is black, and 15 is white. The actual color associated with a color number is detailed in your Applesong suggested problems to write a program for.(1) Generate 40 random numbers between 1 and 39 and store them in a numeric array. Draw 40 vertical lines with the heights of each line corresponding to the number in the array.(2) Write a subroutine that takes two colors and an X and Y co-ordinate and plots a 3 by 3 checkerboard. Then call this subroutine 100 times with random values for the two colors and the X and Y co-ordinate.That's all there is to lo-res graphics. Let's move on to the ne WhiteThe HPLOT CommandFinally like the lo-res PLOT command there is a hi-res HPLOT command. Unlike lo-res' PLOT command HPLOT has several different formats which make it a very powerful command. For example, look at the following:10 fectively only 6 colors.The Hi-Res ColorsThe following are the actual colors and their numbers:Number Color-------------- 0 Black 1 Green 2 Blue 3 White 4 Black 5 Orange 6 Aqua 7 he COLOR command. For example:10 HCOLOR=3would set the hi-res drawing color to color number 3 which is white. The color value can range from 0 to 7, however colors 0 and 4 are both black and colors 3 and 7 are both white. This means there are ef and stop it's execution. In lesson BDT, HGR2 will stop the program. HGR2 commands can be used with standalone BDT.The HCOLOR CommandAgain, analogous to the lo-res COLOR command there is a hi-res HCOLOR command. This works the same way as the two is that HGR2 doesn't let you to use four lines of text at the bottom while HGR does.Due to the memory constraints of this lesson, we can only use the HGR command. The HGR2 command, if executed from BASIC, will overwrite this lesson program-16302,0. In this case the screen dimensions would be 280 by 192.The HGR2 CommandThere are two hi-res screens available on the Apple, screen 1 and screen 2. HGR selects screen 1, and HGR2 selects screen 2. The most obvious difference between tn graphic screen with four lines of text at the bottom. The dimensions of this screen are 280 points across in the X-direction and 160 points down in the Y-direction. Like the lo-res screen, you can make the screen a full screen of graphics with a POKE cs mode, then set a hi-res color and finally plot some hi-res points. The main difference is the higher resolution that hi-res offers.The HGR CommandThe hi-res equivalent of lo-res' GR command is HGR. HGR tells BASIC to create a high resolutioHi-Res GraphicsHGR HGR2 HCOLOR HPLOTHigh resolution graphics (hi-res) is the second graphics mode available on the Apple computer. The concepts in hi-res are the same as in lo-res. First you have the computer turn on it's high resolution graphi SEC(X)1(X)$PI3.141595IPIPIPIB(SEC(I)I2I xt chapter where you'll learn about hi-res graphics.HPLOT 207,14520 HPLOT TO 200,11030 HPLOT 10,10 TO 10,20 TO 20,20Line 10 would plot a single point at 207,145 in the present HCOLOR. Line 20 would draw a line from the last point plotted (in this case 207,145) to 200,110. Line 30 would draw a line from 10,10 to 10,20, and a line from 10,20 to 20,20.Let's go into BDT and watch a example program that uses these commands.L1As you can see, the HPLOT command is very powerful. It performs the same functions as the lo-res PLOT, HLIN and eed to prepare the disk for your Apple. This is called formatting.In order to format a disk, you need to leave this lesson. Make a note of the following steps:(1) Remove the lesson disk from disk drive 1 and replace it with the disk named /USER.ommands and for loading example programs. Pay attention as you move from your disk to the lesson disk and back.Don't worry though, no harm will come if you make a mistake.Formatting a DiskBefore you can use a disk for storing programs or data, you nl you turn it off.In this chapter you will need to supply a disk of your own. If you don't have one, you can still go through this chapter but you won't be able to execute all the examples.You will be using the same disk drive for testing ProDOS cch is short for Professional Disk Operating System. This program is loaded into your Apple when you first turn it on with a disk in the disk drive. This process of loading ProDOS is referred to as "booting" the disk. ProDOS stays in your computer untiDisk BasicsFormat FILER CAT PREFIX CATALOGSince you are now using a disk drive to run this lesson, we will assume that you know a little about using disks and disk drives.All of the disk commands are part of a large program called ProDOS, whi/ "ENTER A STRING OF UP TO 255 CHARACTERS"7S$CL(S$)o("THAT STRING IS ";L;" CHARACTERS LONG"u2}<10 times with random values.You've reached the end of this chapter. Graphics are one of the most interesting topics in computers. They are also a lot of fun!Now it's time to move on to the next chapter.orners of the screen to this point. Repeat 100 times.(2) Write a subroutine that is passed a value from 1 to 20 and an X and Y value. Draw a box whose upper left hand corner is at X,Y and whose side is the value from 1 to 20. GOSUB this routine 50gh it to see its inner workings.L3CXCYSTXSHCYThese are the suggested programs for this chapter. Choose one or more of the following to write in BASIC and test in BDT.(1) Generate a random point on the screen. Draw a line from the four c5)NIHCJNow it's time for one last graphics program. The following example program draws "moire" patterns on the screen.RUN the program first. Once you understand what it does stop it with CTRL-C. Then go into BDT and Step and Trace throuVLIN commands. It can also draw diagonal lines.Let's go into BDT and watch another example program run. This program creates a variable sided figure and draws lines between all the corners.L2X(0)X(1)X(2)X(3)X(4)X(5)Y(0)Y(1)Y(2)Y(3)Y(4)Y(DISK that came with your computer.(2) Turn your computer off and on.CONTINUED...(3) A menu will appear, select PRODOS FILER by pressing F. Then select VOLUME COMMANDS by pressing V. Finally select FORMAT A VOLUME by pressing F.(4) Replace /USER.DISK in disk drive 1 with an unformatted disk.(5) From the FORMAT A VOLUME menu, press RETURN three times to format the disk in SLOT 6, DRIVE 1 with a volume name of /BLANK00.(6) Replace the formatted disk in drive 1 with lesson ot be correct unless you have a real-time clock installed in your Apple.Let's go into BASIC and try the CAT command. You will execute this command from a program in step 1 below and then from the keyboard in step 2. Follow these steps:(1) RUNgramBIN - BinaryREL - Relocatable CodeSome of these files types will be explained as we go on.The BLOCKS field is the amount of space the file takes up on the disk.The MODIFIED field is the date the file was last modified. This field will n It must start with a letter, and can contain letters, digits, and periods ".".The TYPE field is the type of the file. Legal file types are:DIR - DirectoryTXT - TextBAS - Applesoft ProgramVAR - Applesoft VariablesSYS - ProDOS System Pro tells you that 57 blocks of the disk are being used and that 223 blocks are available. A block is 512 bytes or characters. Therefore one "K" is 2 blocks.The NAME field is the name of a file on the disk. A file name must be 1 to 15 characters long.SYSTEM SYS 21 1-SEP-83 STARTUP BAS 7 1-AUG-83 BLOCKS FREE: 223 BLOCKS USED: 57The top line /BLANK00 is the volume name. Each disk or volume has a volume name which you assign when you format the disk.The bottom lineThe CAT CommandHow do you list all the files and programs stored on a disk? You use the CAT command. This is what a typical catalog might look like:/BLANK00 NAME TYPE BLOCKS MODIFIED*PRODOS SYS 29 1-SEP-83 BASIC.hapter, CHR$ is a string function which takes an ASCII code and returns a character. In this case, CHR$(4) is the control character, "CTRL-D". What most programmers do is assign CHR$(4) to the string variable D$. D$ is easier to remember than CHR$(4).ld execute the ProDOS CAT command (which will be explained shortly).10 D$=CHR$(4)20 PRINT D$;"CAT"ProDOS commands used from a program must be printed to work. In addition they must be prefaced with a CTRL-D. If you recall from the Strings cOS commands presented in this chapter, from the keyboard and from within a program.To use a ProDOS command from the keyboard, simply type in the command and press RETURN.Using a ProDOS command from a program is a little harder. The following program wouu wanted the FILER program you would also need the FILER file.To copy these 3 files onto your disk you use the FILER, but we leave this up to you as we do not need the disk to be "bootable".Using ProDOS CommandsThere are two ways you can use the ProDnd programs. It cannot be "booted". If you were to turn your computer on with the disk in drive 1 the message "UNABLE TO LOAD PRODOS" would be displayed. For a disk to be "bootable" it must contain two files:PRODOS and BASIC.SYSTEM.In addition, if yoore proficient, you should take the time to learn about the FILER. The FILER does have various "HELP" screens which can be displayed by typing ? while in the FILER.Bootable DisksThe disk that you just formatted is only suitable for storing data aso lets you execute commands against all the files on a disk. For example you could DELETE all the files whose names began with "TEST" and ended with "ING".It is not necessary to understand the FILER to use your Apple or ProDOS; however as you become mdisk 1 (not disk 2) and turn the computer off and on. Then return to chapter M and this screen.DO IT NOW!The FILERThe program you just used called the FILER is a very powerful program that allows you to copy individual files and disks. It al the program that is in memory.(2) Type CAT and press RETURN(3) Return to the lesson.In both cases you will see the catalog of our disk. As the CAT listing is more than 24 lines long you may want to pause it by pressing CTRL-S. Restart it by pressing any key.M1D$The PREFIX CommandThe PREFIX tells ProDOS which volume name to use when looking for a file. If the volume name of the disk in the disk drive isn't the same as the present PREFIX, you will get a "PATH NOT FOUND" err A$"HAVE A NICE DAY")B$(A$,4)8C$(A$,3)I(D$(A$,6,1)X2E$(A$,8) commands.nds.Now it's time to go to the next chapter. You should understand the basics of using disks before moving on.Keep the disk that you initialized available. We'll use it in the next two chapters.nt information depending on the type of file.It's hard to write any useful program with the commands you've learned in this chapter. In the next chapter, where we show you how to save BASIC programs and variables, you'll get a chance to use these comma a second line.CREATED is the date that the file was created. It is only valid if you have a real-time clock.ENDFILE is the maximum amount of information that the file can contain before it will require another disk block.SUBTYPE displays differeour disk in these various ways.M3D$A$The CATALOG CommandIn addition to the CAT command there is also a CATALOG command. The CATALOG command displays the same information as the CAT command but in addition it displays three extra fields onsk in drive 1.The last is by specifying the actual volume name. For instance, CAT /TEST would search all the disk drives until it found a disk with a volume name of /TEST and then catalog that disk.Let's go into BASIC/BDT and watch a program access yt, that is the ProDOS command you enter will use the present PREFIX. For example, CAT would catalog the present PREFIX volume.The second is with the DRIVE specification seen in the PREFIX command. For instance, CAT,D1 would always catalog the die of the disk in drive 1.Let's go into BASIC/BDT and Step through a program that demonstrates the PREFIX command. Pay attention to the program comments.M2D$A$ProDOS commands allow you to specify a volume name three ways.The first is by defaulessage "PATH NOT FOUND" would be displayed and the PREFIX would remain unchanged.Another way of setting the PREFIX is to use the DRIVE parameter. For instance, if you type in PREFIX,D1 and press RETURN, the PREFIX would be set to the volume namFIX will be displayed.To set a PREFIX for ProDOS to use you would: Type PREFIX /TEST and press RETURN. This would tell ProDOS to attempt to set the PREFIX to /TEST. If there wasn't a disk with this volume name in any of the disk drives, an error mor message. This will happen if ProDOS can't find the file or if ProDOS can't find the PATH to the file. A PATH is the route ProDOS uses to access a file. To find out the present PREFIX type PREFIX and press RETURN in BASIC. The present PREBASIC Disk ProgrammingSAVE LOAD RUN - RENAME DELETE LOCK UNLOCKIn this chapter we will teach you how to SAVE and LOAD programs. In addition we will show you commands that let you manage the files on your disks.In the next chapter, we chapter where you write your own programs. Pick one or more of the following: (1) Write a program that when run will do the following: CAT the disk, SAVE itself onto the disk, CAT the disk again, DELETE itself, and finally CAT the disk for a last , then the file is locked.UNLOCK does the opposite. It takes a locked file and "unlocks" it.Let's go into BASIC and watch a program that uses the commands just presented. Follow the program comments carefully.N1D$We've reached that part of theLOCK and UNLOCK CommandsThe LOCK command lets us "lock" a file on a disk. This means you can't inadvertently DELETE, SAVE to, or RENAME the file. To tell if a file is locked catalog the disk and look in the left hand column. If there is an * oDOS can't find the file a PATH NOT FOUND error would be displayed.The DELETE command is used to remove a file from a disk. For example "DELETE TEMP" would remove the file "TEMP". Again, if ProDOS can't find the file, you will get an error.The .The RENAME and DELETE CommandsThere are several commands like CAT that can be used to manage your disk files.RENAME is used to change a file's name. For example "RENAME TEMP,NEWTEMP" would change the name of the file "TEMP" to "NEWTEMP". If PrThere is another way to run a program. This is the dash - command. For instance, to run a program TEMP on a disk in the drive you could type -TEMP and press RETURN. The dash command will run, not only BASIC programs, but also other types of programs disk in the drive, you could type RUN TEMP and press RETURN. This would LOAD and then RUN the program named "TEMP".Like most ProDOS commands you could use this from within a program. For example, one program could RUN another.The - Commandson disk in the disk drive.The RUN CommandYou've already seen the RUN command in the BASIC Design Tool chapter. However you could only use it if there was a program in the computer's memory. If you wanted to RUN a program named "TEMP" from aollowing:Go into BASIC and type CAT,D1. You should still find "TEMP" on the disk. Type LOAD TEMP,D1 and press RETURN. After the LOADing is completed, LIST the program. It should be the same one that you previously SAVEd.Finally, replace the les on the disk with a file type of BAS.The LOAD CommandThe LOAD command is the opposite of SAVE. It will copy a program from a disk and store it in the computer's memory. If there is a BASIC program already in memory it will be erased. Do the f. Do the following:Go into BASIC and type in a short program.LIST it to make sure it's OK.Put Y O U R disk in drive 1, type SAVE TEMP,D1 and press RETURN ("TEMP" is the name that we'll call it).Type CAT,D1 and you should see a program named "TEMP" will show you how to store and recall data on disks.The SAVE CommandsNow that you know how to format and CATALOG a disk, it's time to learn how to save a program. The SAVE command moves a BASIC program from the computers memory onto a disktime.(2) This program is called a "Backup" program. When you run it, it should do the following: DELETE a file called "OLD.TEMP" off of the disk, RENAME a file named "TEMP" to "OLD.TEMP". SAVE itself as TEMP.Now it's time to go to the next chapter. There we'll present the disk commands you would use when creating and using data text files. You should understand the commands in this chapter before moving on.Keep the disk that you initialized available. We'll use it in the next chapter.IS WORD" $T$6 &"YOU HAVE ";MISSES;" MISSE(S)"c ,(T$,2)SECRET$ĺ"YOU GUESSES IT!":340w 6MISSES10ī200 @"YOU ARE HUNG!" J"THE WORD WAS ";SECRET$ T ^"WANT TO PLAY AGAIN? (Y/N) "; hQ$:Q$ rQ$"Y"ī90 | "ENTER YOUR ONE LETTER GUESS -->";2 G$:G$p G$"A"G$"Z"ĺ"LETTER MUST BE BETWEEN 'A' AND 'Z'":200} SWITCH0 I1(SECRET$) (SECRET$,I,1)G$T$(T$,I)G$(T$,I2):SWITCH1 I "SWITCH0MISSESMISSES1:"NO '";G$;"' IN TH  W$(9)` ANIMAL,JOYSTICK,PENCIL,COMPUTER,SEASHORE,APPLE,SHOELACES,TRUMPET,SCHOOL,EAGLEkI09v(W$(I)}2IZdI(1)10nSECRET$W$(I)T$(" ----------",(SECRET$)1)MISSES0"SECRET WORD GENERATED"& ) = ";CODE CODE " STR$ AND VAL DEMONSTRATION+A10@S$"TEN = "(A)Q(B((S$,7))]2S$,A,B~d ASC AND CHR$ DEMONSTRATIONnI112x A,B,C,D,1,2,3,4,&,',(,)C$CODE(C$)ICODE6590C$(CODE) "ASC(";(34);C$;(34);" S$"THE QUICK BROWN FOX"=S1$(S$,4)"SLOW"(S$,4)bS2$"HOW NOW "(S$,11,5)" COW"y(S3$(S$,3)" END"2S1$<S2$FS3$ 2 @)$($`ID  D$(4)D$"CAT" # "ENTER A SECOND NAME -->";N$C"ENTER A SECOND AGE -->";AIx("PLACE YOUR INITIALIZED DISK IN THE DISK"2"DRIVE. PRESS RETURN WHEN READY. ";Q$<D$(4)> LET'S SET THE PREFIX@D$"PREFIX /BLANK00"FD$"APPEND NAME.AND.AGE"d"YOUR NAME IS : ";N$6n"YOUR AGE IS : ";A<xj"PLACE THE LESSON DISK BACK IN THE DISK""DRIVE. PRESS RETURN WHEN READY. ";Q$ 0 "PLACE YOUR INITIALIZED DISK IN THE DISK"]"DRIVE;. PRESS RETURN WHEN READY. ";Q$iD$(4) LET'S SET THE PREFIX"D$"PREFIX /BLANK00"(D$"OPEN NAME.AND.AGE"2D$"READ NAME.AND.AGE"<N$FAPD$"CLOSE NAME.AND.AGE"ZK IN THE DISK"<"DRIVE. PRESS RETURN WHEN READY. ";Q$B BD$"OPEN NAME.AND.AGE"6CD$"CLOSE NAME.AND.AGE"SDD$"DELETE NAME.AND.AGE"zE CREATE THE NEW NAME AND AGE FILEFD$"OPEN NAME.AND.AGE"PD$"WRITE NAME.AND.AGE"ZN$dAnD$"CLOSE NAME.AND.AGE"x"PLACE THE LESSON DISK BAC "ENTER YOUR NAME -->";N$;"ENTER YOUR AGE -->";AAn("PLACE YOUR INITIALIZED DISK IN A DISK"2"DRIVE. PRESS RETURN WHEN READY. ";Q$<D$(4)= LET'S SET THE PREFIX>D$"PREFIX /BLANK00"A ERASE AN OLD NAME AND AGE FILEA$  D$(4), LET'S USE THE DEFAULTS. 9D$"CAT"W( LET'S USE DRIVE OPTION.g2D$"CAT,D1"< LET'S USE A VOLUME NAME.F FIRST WE GET IT WITH THEP PREFIX COMMAND.ZD$"PREFIX"dA$n NOW LET'S CAT THIS VOLUMExD$"CAT ";$ F(K NOW LET'S SET THE PREFIX;PD$"PREFIX,D1"WZ LETS SET IT DIRECTLY.kdD$"PREFIX ";A$n WHY NOT ESCAPE TO BASIC ANDx TYPE 'PREFIX' YOURSELF.$ FIRST, LET'S READ THE PREFIX: FROM A PROGRAM.FD$(4)V(D$"PREFIX"^2A$< NOTE THAT IT TAKES TWO STEPS.A FIRST WE EXECUTE A PREFIXB COMMAND. THEN WE FOLLOWC WITH A INPUT COMMAND.D THE PREFIX WILL BE STORED IN APD$"WRITE NAME.AND.AGE"%ZN$,dAHnD$"CLOSE NAME.AND.AGE"Nx|"PLACE THE LESSON DISK BACK IN THE DISK""DRIVE. PRESS RETURN WHEN READY. ";Q$ 0 "PLACE YOUR INITIALIZED DISK IN THE DISK"]"DRIVE. PRESS RETURN WHEN READY. ";Q$iD$(4) LET'S SET THE PREFIX"D$"PREFIX /BLANK00"(D$"OPEN NAME.AND.AGE"2D$"POSITION NAME.AND.AGE,R2"<D$"READ NAME.AND.AGE"FN$P  P0(0)P1(1):"PDL(0)=";P0;" PDL(1)=";P1B(10 IVE. PRESS RETURN WHEN READY. ";Q$+ <I3ī200.FD$"OPEN NAMES.AND.AGES,L35"OPD$"READ NAMES.AND.AGES,R";IWZN$^dA|nD$"CLOSE NAMES.AND.AGES"x"RECORD NUMBER ";I"NAME : ";N$"AGE : ";A30"PLACE THE LESSON DISK BACK IN THE DISK"%"DR0 "PLACE YOUR INITIALIZED DISK IN THE DISK"\"DRIVE. PRESS RETURN WHEN READY. ";Q$hD$(4) LET'S SET THE PREFIXD$"PREFIX /BLANK00"("WHICH RECORD DO YOU WANT? (0-3) ENTER"2"A NUMBER GREATER THAN 3 TO EXIT. -->";I MES.AND.AGES,R"IN$(I)'A(I).ILD$"CLOSE NAMES.AND.AGES"z"PLACE THE LESSON DISK BACK IN THE DISK""DRIVE. PRESS RETURN WHEN READY. ";Q$ PREFIX"zD$"PREFIX /BLANK00"F} ERASE THE NAMES AND AGES FILEc~D$"OPEN NAMES.AND.AGES"D$"CLOSE NAMES.AND.AGES"D$"DELETE NAMES.AND.AGES" CREATE NEW NAMES AND AGES FILED$"OPEN NAMES.AND.AGES,L35"I03D$"WRITE NA N$(3),A(3)I03;"ENTER NAME # ";I;" -->";I("";N$(I)g2"ENTER AGE # ";I;" -->";t<"";A(I){FIPZ"PLACE YOUR INITIALIZED DISK IN THE DISK"d"DRIVE. PRESS RETURN WHEN READY. ";Q$nxD$(4) y LET'S SET THEA ZD$"CLOSE NAME.AND.AGE"&dPn"THE SECOND NAME (RECORD 2) IS : "N$yx"THE SECOND AGE (RECORD 3) IS : ";A"PLACE THE LESSON DISK IN THE DISK DRIVE""AND PRESS RETURN WHEN READY. ";Q$  BUT(X)(16287X)127-B0BUT(0)<B1BUT(1)]("BUT(0)=";B0;" BUT(1)=";B1e220  30,390'(0,3939420,3939@<0,390GF8TP1,3820aZ1,3820mdC0,0){nC10,10)xC20,20)C39,39)  16302,00)(Y4047520,39Y<<YJdC(1)16QiC`nX1(1)40oxX2(1)40}Y(1)48X1X2ĎX2,S1Y:160X1,X2YY1(1)48Y2(1)48X(1)40Y1Y2ďY2,Y1X:210Y1,Y2X100  16302,00)(Y404752X039><X,YEFXLPYZdC(1)16anCoxX(1)40}Y(1)48X,Y100  C115C"(YC-2X096<X,Y=FXDPC 55 0,100 1,255# 7686 PLAY A SCALEC P1255L 0,PV 1,10_ 768f P  POKE IN SOUND ROUTINE` 173,48,192,136,208,4,198,1,240,8,202,208,246,166,0,76,0,3,96rI76876818y(C2I,C<Id PLAY A NOTEn MEMORY LOCATION 0 IS THE PITCHx LOCATION 1 IS THE DURATION BOTH VALUES RANGE FROM 0-2 S16336I1200&X(S)-(I:2I1100E<X(S)PFJ14WPJ^ZI  I110(7);I%(  ' MAKE FULL SCREEN GRAPHICS516302,0<(0I2Y4047U<0,39Y\FYqd PLOT A BOARDERxn3x0,3900,47390,39470,470 SET INITIAL POSITIONX20Y20 SET BALL COLORCB4 SET BA COUNT(9)D09)COUNT(D)00(DY2"ENTER A STRING OF UP TO 50 DIGITS"h<"-->";ST$xFI1(ST$)PC$(ST$,I,1)ZD09dC$(D)COUNT(D)COUNT(D)1:D9nDxID09"THERE ARE ";COUNT(D);" ";D;"'S" D CX(1)280'CY(1)1607(ST(1)42G2X0278STR<S01]FHC3SePHCZXS,0CX,CY279XS,159dSnXxY0158STS01HC3SHC279,YSCX,CY0,159YSSY10 DO IT ALL AGAIN 20  X(9),Y(9)2GENERATE RANDOM POINTSA(N(1)91L2I0N^<X(I)(1)280pFY(I)(1)160wPId CONNECT ALL POINTSnHC(1)8x(HC)0(HC)4ī110HCI1NJ0IX(I),Y(I)X(J),Y(J)JI  3/0,0279,0279,1590,1590,0@(0,0279,159Q2279,00,159  30,3910!('2@<"BACK TO TEXT MODE"FFMP7ZZ0,3920`dfn Y  CLEAR OLD BALL 0( &X,YI 0 MAKE PRESENT POSITION, OLDR :XBX[ DYBYq X DO IT ALL AGAINz b300 LLS VELOCITY VX1 VY1C , MOVE BALL IN THE X DIRECTIONO 6BXXVXd @BX0BX39ī400o JVXVXx T300  MOVE BALL IN THE Y DIRECTION BYYVY BY0BY47ī500 VYVY 400  PLOT BALL AT NEW POSITION CB BX,B Text FilesOPEN CLOSE WRITE READ POSITION APPENDThe last chapter introduced the disk commands for saving and loading BASIC programs. Disk management commands were also presented.In this chapter we will present those ProDOS commands necessary ftend to READ instead of WRITE with the following command:50 PRINT D$;"READ NAME.AND.AGE"Second, we use INPUT commands to READ the data instead of PRINT commands to WRITE the data.O2D$N$AQ$The APPEND CommandThere is another optis.Let's go back into BDT and watch the program run again.O1N$AQ$D$Let's run a program that reads the text file we created in our last example. As you will see there are two differences. First, after we OPEN the file, we tell ProDOS that we ineed to do one final thing; CLOSE the file. For example, in our program we used:110 PRINT D$;"CLOSE NAME.AND.AGE"This tells ProDOS to close the file named "NAME AND AGE". We could have left off the name and ProDOS would have closed all OPEN filee file called NAME.AND.AGE. The reason the output doesn't appear on the screen is because we told ProDOS to capture any output and store it in the text file.The CLOSE CommandWhen we've printed all the information we want to the open text file, we ninformation we want the file to hold. For this we use a normal PRINT command. For example, in our program we used:90 PRINT N$100 PRINT AThese two commands copied the values in string variable "N$" and numeric variable "A" consecutively into thWRITE to the file with80 PRINT D$;"WRITE NAME.AND.AGE"Once this command is executed all output from subsequent PRINT commands will go to the presently open file.Once we've told ProDOS to OPEN the file for output we need to store the actual er.There are a couple of initial steps to creating a text file. First we must OPEN it. For example:70 PRINT D$;"OPEN NAME.AND.AGE"says: "create a file called NAME.AND.AGE".The WRITE CommandSecondly, we must tell ProDOS that we intend to ? If you got a ProDOS error message look it up in the ProDOS manual that came with your computer and figure out where you went wrong.Did you notice the way the ProDOS commands were used from a PRINT command? This was explained in the Disk Basics chapte last chapter.The program itself will tell you when to insert your disk and when to replace the lesson disk, so just follow the instructions that the program prints out while you Step the program in BDT.O1N$AQ$D$The OPEN CommandDid it workand them, you will find it easier to learn about random access files.Let's start by showing you a simple program that creates a small text file on the disk. The program will INPUT your name and age and store them on the disk you formatted in thTypes of Text FilesThere are two types of text files, sequential and random access.Sequential files are a list of strings and numbers stored on the disk. They are the easiest to understand so we will present them first. Once you understor using data files on disk. Disks are used to store data when you need a permanent copy. For instance, if you were to write a checkbook program, you would need some way to save data after the computer is turned off. For this you would need a disk file.on besides OPEN that is used when PRINTing to a file. This is APPEND, which is used to extend a file.The following example program adds a second name and age to the file called "NAME.AND.AGE". Notice where previously we used the OPEN command we now use the APPEND command.O3N$AQ$D$The POSITION CommandAs you can see, sequential text files are best suited to sequential data. What do we do if we want to read a record that is stored many records deep in the file? We would use the Program may seem trivial, the same techniques could be extended to a file containing many records.O6Q$D$IN$ANow it's time to write some programs using the disk commands we have presented here.(1) Write a small program that will save your nam "I".Let's access data in the file we just created. The following program will ask you which record number you wish to access. It will then OPEN the file and READ the specified record. Finally it will print the record on the screen. While this practers. The second thing you should have noticed is the way we used the WRITE command:150 PRINT D$"WRITE NAMES.AND.AGES,R"IAn extra item was added on this command also. This is the ,R"I. This told ProDOS that we wanted to write to record (cell)m. The first is the way we opened the file:130 PRINT D$"OPEN NAMES.AND.AGES,L35"An extra item was added to the OPEN command. This is the ,L35. This told ProDOS the file was going to be a random access file and each cell would have at most 35 chamost 3 digits. The total would be 35 characters. The extra 2 characters are for the hidden RETURN characters at the end of each record.O5N$(0)N$(1)N$(2)N$(3)A(0)A(1)A(2)A(3)D$IQ$There are two things to notice about the last example progratext file containing 4 cells. Each cell will contain a name and an age. Before writing this program we had to figure out how much space each name and age would take. We decided that each name would take up at most 30 characters. Each age would take at dom access files are files containing a series of cells on a disk. Each cell takes up the same number of characters. This allows ProDOS to quickly calculate the position of a given cell. As an example, let's run a program that creates a random access d it had to search through the first three. This can take a lot of time if files are large. What is needed is some way for ProDOS to know where each record begins so it can jump there and start READing. Random Access Text Files are the answer.RanilesIn the previous example, we used the POSITION command to access a record out of sequence. This is fine if the file only has 4 records. However, what if the file has 1000 records? Although you didn't realize it, for ProDOS to find the fourth recorD$;"DELETE NAME.AND.AGE"Line 40 OPENs the file. If it exists it will OPEN the old version. If it doesn't it will OPEN a new version. Line 50 CLOSEs the file. Finally line 60 DELETEs the file whether it is old or new.Random Access Text F You get a "PATH NOT FOUND" error. To structure this type of program to work regardless of whether it has been run or not, you need to include the following three commands:40 PRINT D$;"OPEN NAME.AND.AGE"50 PRINT D$;"CLOSE NAME.AND.AGE"60 PRINT s if the file your program is attempting to create already exist (maybe from a previous run of the program). The solution seems easy enough, you would simply enter:40 PRINT D$;"DELETE NAME.AND.AGE"The problem appears if the file does not exist.(if we used POSITION right after OPEN).The following example program demonstrates the use of the POSITION command.O4D$N$AQ$Deleting Files That May Not ExistWhen you are writing a program that creates a text file you may experience problemOSITION command. The POSITION command is usually used after a OPEN command and before a READ command. The record that we POSITION to is relative to the present position in the file. This means the record 0 would be the first record in the file e, address, and phone number in a sequential text file. Then write another program that will read the file and print it on the screen.(2) Write a program that will create a small file with up to 25 items. Each item will have a 10 character name, and a quantity of up to 5 digits. Then write another program that will INPUT a record number and print out the item's name and quantity.CONGRATULATIONS!You've made it all the way through.For more in depth information you should consult your BASIC cause the RESTORE command would force the next READ to get the first piece of DATA, again.Using ArraysThe usefulness of READ and DATA cannot be fully appreciated until we use arrays. You know that a variable holds a single value. An arrndA command sometimes used with READ and DATA is RESTORE. This command resets READ to start with the first piece of data in the DATA command.In this program:10 DATA 1,2,320 READ A30 RESTORE40 READ BA would equal 1, but so would B bee'll see printed is 1, 5, 7, and so on.Eventually the program will run out of DATA to READ and will stop with a BASIC error OUT OF DATA. After the error, press CTRL-B to get back into BDT. Let's watch it in BDT.G1NUMBERThe RESTORE Comma to variables.Look at the following program:10 DATA 1,5,7,13,1720 READ NUMBER30 PRINT NUMBER40 GOTO 20Line 10 contains the DATA to be READ in line 20. Line 30 will print the value of NUMBER, and line 40 will loop back to line 20. What wArraysREAD DATA RESTORE DIM SortingREAD and DATA provide another way to assign values to variables:10 READ A,B,C20 DATA 2,4,6will do the same as:10 A=2:B=4:C=6READ and DATA together provide a shorthand way to assign valuesHEN READY -->";D$ D$"CAT"! LET'S RENAME IT@D$"RENAME BBBTEST,NEWBBB"\ DID IT'S NAME CHANGE?iD$"CAT" FINALLY, LET'S DELETE IT D$"DELETE NEWBBB" IS IT GONE?D$"CAT""REPLACE THE LESSON DISK IN IT'S DRIVE.""PRESS RETURN WS SEE IF IT'S ON THE DISK(FD$"CAT"@P NOW LET'S LOCK ITVZD$"LOCK BBBTEST"nd LET'S SEE THE "*"{nD$"CAT"x NOW LET'S UNLOCK IT SINCE WE CAN'T RENAME OR DELETE A LOCKED FILED$"UNLOCK BBBTEST" IS THE "*" GONE? ("PUT YOUR DISK IN A DRIVE."S"PRESS RETURN WHEN YOUR READY -->";D$_ D$(4) FIRST LET'S SET THE PREFIXD$"PREFIX /BLANK00" THEN LET'S SAVE THIS PROGRAM SO WE'LL HAVE SOMETHING TO USE2D$"SAVE BBBTEST"< LET'and ProDOS manuals.On disk 2 there is an advanced version of the BASIC Design Tool called Standalone BDT. To use this version you must turn on your computer with disk 2 in drive 1. The User's Manual contains a tutorial and an in depth summary of it's ay holds a list of values.Variable:xArray:AGE=17xAGE(0)=12xAGE(1)=14AGE(2)=29AGE(3)=2The array AGE actually contains 4 different variables which share the same name.We say AGE sub zero for AGE(0),AGE sub one for AGE(1), etc.Arrays are useful when variables are used to index them.AGE(A)means:Take the value of A and use that element of array AGE.So,10 A=320 AGE(A)=7Sets the third element in array AGE, AGE(3), equal to 7.The DIM CommandWe tell BASIC thatis time input the numbers 0, 1, 2, 3, 4, 5, 6, 7 to sort.G4NUMBS(0)NUMBS(1)NUMBS(2)NUMBS(3)NUMBS(4)NUMBS(5)NUMBS(6)NUMBS(7)IJHOLDDid you notice the program sorted the numbers even though they were already in order?How dumb!The next sort swhat we have shown you before continuing.The rest of the chapter deals with advanced sorting concepts. If this doesn't interest you, skip ahead to the end the chapter for the sample programs.Let's enter BDT again and run the same sort one last time. Th2, 3, 4, 5, 6, 7, 0 to be sorted.Watch how the 0 bubbles up into place.G4NUMBS(0)NUMBS(1)NUMBS(2)NUMBS(3)NUMBS(4)NUMBS(5)NUMBS(6)NUMBS(7)IJHOLDYou should understand arrays and sorting to go on. If you have any doubts, please review ) is moved to a variable named HOLD. Then NUMBS(J+1) is moved to NUMBS(J). That's why we moved NUMBS(J) to HOLD. Then HOLD is moved to NUMBS(J+1). This completes the swap.Let's run the last example again under BDT. This time enter the numbers 1, NUMBS(J)=NUMBS(J+1):NUMBS(J+1)=HOLDJ is being varied from 0 to 6. The condition in the IF command looks at NUMBS(J) and tests to see if it is larger than NUMBS(J+1). If it is, then the two are out of order and must be swapped. First NUMBS(Jrogram had to compare 9 pairs of numbers 10 times. The more numbers we wanted to sort, the longer it would have taken.And you thought computers were fast!Did you understand the comparison statement?1130 IF NUMBS(J)>NUMBS(J+1) THENHOLD=NUMBS(J):ple program several times in BDT and pay careful attention to the routine that actually sorts.G4NUMBS(0)NUMBS(1)NUMBS(2)NUMBS(3)NUMBS(4)NUMBS(5)NUMBS(6)NUMBS(7)IJHOLDDid you notice how long the bubble sort took?To sort 10 numbers the p)=19A(1)=3A(2)=7 and ending up withA(2)=7A(3)=-1A(3)=12A(4)=3A(4)=19There are many ways to sort. Here's the simplest. It's called a bubble sort because out-of-order elements "bubble" to the correct place in the array.Run the sam(9,9)YXSorting ArraysIt's time to use arrays to their full advantage.Sorting is a technique by which unordered arrays can be ordered, or unalphabetized lists can be alphabetized.By this we mean taking an array like:A(0)=12A(0)=-1A(1 or matrix.Let's go into BDT and watch a program create a multiplication table and store it in a two dimensional array.G3MULTTABLE(1,1)MULTTABLE(2,2)MULTTABLE(3,3)MULTTABLE(4,4)MULTTABLE(5,5)MULTTABLE(6,6)MULTTABLE(7,7)MULTTABLE(8,8)MULTTABLErencing array elements. BASIC allows you to create multiple dimension arrays which can have up to 88 indices. The following would create a two dimensional array with 100 elements:10 DIM A(9,9)A two dimensional array can be thought of as a table values.G2CARPRICE(0)CARPRICE(1)CARPRICE(2)CARPRICE(3)CARPRICE(4)CARPRICE(5)CARPRICE(6)CARPRICE(7)INMultiple Dimension ArraysThe arrays we have seen so far have been single dimension arrays. This means the array had one index for refeBut what can we do with arrays?We're glad you asked...One way to use arrays is with the READ and DATA commands.The next example program dimensions an array named "CARPRICE", READs values into the array, and then allows us to access those we want an array to have a certain number of elements by using the DIM (dimension) command:10 DIM AGE(4)Tells BASIC to create:AGE(0), AGE(1), AGE(2), AGE(3) and AGE(4).*** Notice there are actually 5 elements because the array starts at 0.ets a switch during each pass through the array if any swaps were made. After each pass the switch is checked for swaps. If no swaps were made then the array is completely sorted.Try this one several times and see how much smarter and faster it is.G5NUMBS(0)NUMBS(1)NUMBS(2)NUMBS(3)NUMBS(4)NUMBS(5)NUMBS(6)NUMBS(7)IJSWAPSHOLDHold on to your hats!We're going to get fancy!Did you notice the preceding sorts could bubble down very quickly, but bubbled up just one step for each pass thr 1,5,7,13,17NUMBER*NUMBER2(20 back.Why not backup and write the other suggested program if you have not already done so.That's all for ARRAYS. Time to move on to the next chapter.fter the tenth, print them out using another FOR/NEXT loop.(2) Initialize an array of ten numbers using READ and DATA inside a FOR/NEXT loop. Use INPUT to read a number from 0-10. If it is 0 then stop. Otherwise, print that array element and loopnteger array by ending the name with % . For instance, I%(10) would be a valid integer array element.Practice the concepts covered in this chapter by writing these suggested programs.(1) In a FOR/NEXT loop input ten numbers into an array. Am, however as programs get larger you may want to use integer arrays. Integer array elements take only 2 bytes of storage, while reals take 5 bytes (a byte is the basic unit of storage in a computer).You tell the computer that an array will be an iUMBS(0)NUMBS(1)NUMBS(2)NUMBS(3)NUMBS(4)NUMBS(5)NUMBS(6)NUMBS(7)ITBSWAPSHOLDInteger ArraysAll the arrays we have been using were real arrays. This means that each element of the array was a real number. This is fine for a small progras during each pass. This is possible because on each pass the most out-of-order element will be deposited in the correct place, and we never need to look at it again.Enter BDT and try to figure out the two-directional, shortened path bubble sort.G6Nough the array?Backup and go through the sort again if you did not notice this.Our next sort bubbles down and then up. This way the most out-of-order elements are grabbed and moved into place quicker.This sort also shortens the number of comparison