Straight to the Point (PC World August 1985 by D. Illowsky & M. Abrash) The DRAW statement controls what can be visualized as a multi- inked pen that draws on your computer screen. The pen can move to any point on the screen, leaving a trail, in a color you choose, as it moves. The DRAW statement includes features to "lift" the pen from the screen at any point, paint the figures you draw, scale them to any size, and rotate then to any angle. Familiarity with the DRAW statement will open up a world of new applications and ideas for enhancing your programs. Your PC must have a graphics display (color is recommended) and a graphics board. The PC offers two graphics modes -- medium resolution and high resolution. Medium resolution splits the screen into 320 columns by 200 rows of pixels; screen coordinates stretch from location 0,0 at the upper left corner of the screen to location 319,199 at the lower right corner. In this mode you can draw forms in any of four colors. In high-resolution mode the screen is divided into 640 columns by 200 rows, with coordinates stretching from 0,0 at the upper left corner to 639,199 at the lower right. High-resolution figures can be drawn only in black and white. The examples below call for medium-resolution mode so you can use color, but the DRAW statement uses the same commands in high-resolution mode. Before beginning, ready the screen for graphics. The DRAW statement is available only in BASICA. After loading BASICA, enter NEW to clear memory and reset all DRAW parameters to their default values. Select medium-resolution mode by entering SCREEN 1. Then turn off the function key descriptions at the bottom of the screen with KEY OFF, and clear the screen by typing CLS . The examples will use the default palette, 1. (For information on changing palettes, see the COLOR statement section of the BASIC manual.) Moving the Pen The DRAW statement is given in the form: DRAW commandstring where commandstring consists of a string of subcommands of the DRAW statement, in either uppercase or lowercase. The subcommands are: - - - - - Subcommand Description Movement Mx,y Move. If x is preceded by a plus or minus subcommands sign, the distance moved is relative to the last point referenced; otherwise, the move is absolute to x,y. If the move is relative, distance represented by x and y are in pixels unless set to a different scale of the S subcommand. Un Move up. The distance moved is n units; actual distance covered is determined by the S subcommand. Dn Move down. Rn Move right. Ln Move left. En Move up and right (northeast). Fn Move down and right (southeast). Gn Move down and left (southwest). Hn Move up and left (northwest). Pen control B Blank. Don't draw any points when executing subcommands the next subcommand. (prefixes) N No move. Return to starting position after executing the next subcommand, without changing the last point referenced. Environment Cn Color. Select color 0, 1, 2, or 3 to draw subcommands with. Sn Scale. Select figure scaling size, 1 being the smallest and 255 the largest. The scale is n/4. The default is n = 4, or 1 unit = 1 pixel. An Angle. Rotate figures 0, 90, 180, or 270 degrees, with n equal to 0, 1, 2, or 3, respectively. TAn Turn angle. Rotate figures at any angle (n) between -360 and +360 degrees (+ indicates degrees counterclockwise; - indicates degrees clockwise). Pp,b Paint. Fill in with color p the area bounded by color b. - - - - - The simplest DRAW subcommand is the move subcommand M, given as: DRAW "Mx,y" where x and y are the screen coordinates at the pen's destination. Type the command: DRAW "M100,100" and see what happens. Unless you turn this feature off, the M subcommand leaves a trace of all the pen's movements across the screen. The movement subcommands of the DRAW statement draw a line between the last point referenced (LPR) by a BASIC command and a new point you specify. If no point has yet been referenced, the LPR defaults to the point at the center of the screen (coordinates 160,100 in medium-resolution mode). If you do not want to use the center as your initial starting point, you can set a point with the PSET command before issuing the M subcommand. Clear the screen and enter: PSET (50,50):DRAW "M150,150" This PSET statement sets the LPR to 50,50. After subsequent DRAW subcommands, the LPR advances to the last pen position. You can specify screen locations for the M subcommand in two ways. With absolute addressing, a given coordinate pair always describes the same point on the screen. Relative addressing describes a location relative to the LPR. Distance is measured in pixels unless you give a command to change the scale factor; the relative coordinates are added to the coordinates of the LPR to give the actual screen location. The M subcommand is the only DRAW subcommand that uses absolute addressing; the others always use relative addressing. If the x coordinate is prefixed with a plus or minus sign, then both x and y are treated as relative coordinates. If x is not prefixed with a sign, then both parameters are treated as absolute coordinates. For an example of screen addressing with the M subcommand, clear the screen and enter: PSET (100,100) DRAW "M150,100;M+0,50;M-50,-50" to draw a triangle. The first move subcommand uses an absolute address while the last two use relative addressing. As this example shows, you can combine several DRAW subcommands in a single string. To increase readability you can insert semicolors and/or spaces between DRAW subcommands; in fact, semicolons are required in certain circumstances. BASIC strings can be 255 characters long, but before one DRAW command picks up where the last left off, lengthy command strings are generally not necessary; several short (and more readable) strings will almost always do as well. The DRAW subcommands U, D, L, and R duplicate the function of the M subcommand for specific movements. These commands move the invisible pen a specified distance up, down, left, and right, respectively. The U subcommand takes the form: DRAW "Un" where n is the distance to move. If n is not specified, a default of 1 is used. The other three subcommands use the same syntax, except, of course, that the appropriate letter D, L, or R is substituted for U. Clear the screen and enter: DRAW "U40 L60 D40 R60" to draw a rectangle. Each subcommand starts from the endpoint of the previous movement (the LPR). Note that this command is considerably more compact and intelligible than DRAW "M+0,-40 M-60,0 M+0,40 M+60,0". Four more movement subcommands, E, F, G, and H, draw diagonally, moving up and right, down and right, down and left, and up and left, respectively. These subcommands are obviously not as easy to remember as the last four. However, you can keep in mind that the E subcommand points up and right, or northeast, and the other three subcommands fall into place clockwise. These subcommands are issued in the same form as the other direction subcommands. The distance represented by n is somewhat different with this set of subcommands, because pixels are spaced farther apart in a diagonal direction than they are horizontally or vertically. Thus a given distance, as specified by n, will be about 1.4 times as far diagonally as horizontally or vertically. This enables commands such as DRAW "R10 D10 H10" to produce closed figures. If n is omitted, the distance parameter defaults to 1. KITE.BAS uses the M subcommand to make an initial move to an absolute position, and thereafter uses the movement subcommands. The M subcommand is preferable to the movement subcommands only for an absolute move or a move that is not exactly diagonal, horizontal, or vertical. 100 'KITE.BAS: Program to demonstrate DRAW statement movement 110 'subcommands by drawing a kite. 120 SCREEN 1,0:COLOR 0,1:KEY OFF:CLS 130 DRAW "m240,40" 'Draw string 140 DRAW "u20 d40 u20 120 r40" 'Draw cross 150 DRAW "g20 h20 e20 f20" 'Draw outline 160 END Lifting the Pen With the previous DRAW subcommands you can move the pen to any point on the screen, but it always leaves a trail as it moves. Sometimes you'll want to "lift" the pen off the screen and move it to a new location (reset the LPR) without leaving a line. This trick is accomplished with the B, or blank, subcommand. The B subcommand is used as a prefix to any subcommand that sets a screen position. Subcommands prefixed with B have no effect on the screen. Clear the screen and enter: PSET (160,100):DRAW "BM+99,99" This DRAW command draw no line, but it does move the LPR, as you will see if you enter (without clearing the screen): DRAW "U100" The B subcommand lifts the pen only for the duration of the single subcommand following it. To suspend the pen for several successive subcommands, you must prefix each subcommand separately with B. An M subcommand prefixed with B is a good way to set the LPR, because unlike the PSET statement, this method doesn't affect the screen in any way. Another pen control subcommand, N, allows you to move the pen without changing the LPR. Like B, N operates as a prefix to any subcommand that sets a screen position. The N subcommand makes it very easy to draw figures around a central point. For example, clear the screen and enter: DRAW "NU30 NR30 ND30 NL30" Each subcommand starts from the same point, since the N prefix keeps the LPR from changing. DRAW Environment Subcommands Four DRAW subcommands set the environment in which other DRAW subcommands execute. The first two -- C and S -- control color and scale. The second two -- A and TA -- control rotation. The C subcommand governs the color in which figures will be drawn. It takes the form: DRAW "Cn" In medium resolution, n is 0 for the background color or 1 through 3 for one of the other available colors (cyan, magenta, and white, respectively, in palette 1). In high-resolution mode, n is 0 for black or 1 for white. If no C subcommand has been executed, the color defaults to 3 in medium-resolution mode and to 1 in high-resolution mode. After the C subcommand is executed, all pixels drawn by the DRAW statement will be in color n until another C is executed, memory is cleared, or another graphics statemtn using a different color is given. The C subcommand does not affect the color used by graphics commands other than DRAW. Clear the screen and enter: DRAW "C1 L50 C3 D40 C2 M+50,-40" to use three of the four colors available in medium-resolution mode. Then, leaving the screen unchanged, erase the image just drawn by drawing it again in the background color. Enter: DRAW "C0 L50 D40 M+50,-40" Then enter: DRAW "C3" to reset the DRAW color to 3, white. The Scale Subcommand The distance the pen moves for any DRAW command depends on the current scale factor. The default for the scale factor is 1 distance unit = 1 pixel, so unless an S (scale) subcommand is executed, the n parameter of any movement subcommand equals n pixels. Changing the scale factor enables you to use the same DRAW command string to draw a given figure in any number of sizes. The S subcommand does not affect the absolute address form of the M subcommand or any graphics command other than DRAW. The S subcommand is used in the form: DRAW "Sn" where n is the scale factor, expressed as a number between 1 and 255. The statement sets the number of pixels drawn for each unit of distance as n/4. Thus, for example, if n is 4, then 1 pixel (4/4) is drawn for each unit of distance specified. (Four is the default scale factor.) If n is 2, then half a pixel (2/4) is drawn for each unit. Clear the screen and enter: DRAW "S4 R40" Then, leaving the screen unchanged, enter: DRAW "S1 BU8 L40 The second statement produces a line only 1/4 the length of the first line even though the distance parameter is the same, because the scale factor has been changed. For an example of the scale subcommand's use, store the command string for a diamond shape in the string variable D$ by entering: D4="E20 F20 G20 H20" Then clear the screen, and draw the figure in four sizes by typing: DRAW "BM0,110 S1"+D$ DRAW "BM20,110 S4"+D$ DRAW "BM70,110 S8"+D$ DRAW "BM160,110 S16"+D$ (Reuse the same command line for each DRAW statement so the text doesn't wander into the figures you draw.) When used with strings, the plus sign concatenates two strings into one. Thus, in the first DRAW statement in the preceding example, DRAW "BM110 S1"+D$ is equivalent to DRAW "BM0,110 S1 E20 F20 G20 H20". The scale subcommand works as neatly with complex forms like schematic symbols as with the simple diamond used here. The scale factor remains in effect until another scale factor is set or until CLS, NEW, or a new program is executed. Enter: DRAW "S4" to reset the scale factor to the default. The Angle Subcommands Two DRAW environment subcommands, A and TA, are used to rotate a figure. The A subcommand (the only angle subcommand available in BASIC earlier than 2.0) can rotate a figure only by 0, 90, 180, or 270 degrees. The TA subcommand, available in versions of BASIC later than 2.0, can rotate a figure to any angle. These subcommands work by rotating the reference axes (the x and y axes of the screen). Any figure drawn will align with the new axes. The syntax of the A subcommand is: DRAW "An" where n is 0, 1, 2, or 3, corresponding to rotations of 0, 90, 180, or 270 degrees. The angle subcommands affect all DRAW subcommands except the absolute address version of the M subcommand, but do not affect any graphics commands other than DRAW. The ability to change the angle of a figure is not particularly useful when you are drawing the figure only once, but its value becomes apparent when you want to show a predefined figure in a number of attitudes. For an example, define a flat rectangle by entering: F$="U10 R60 D10 L60" Then clear the screen and enter: DRAW "BM160,130" DRAW "A0"+F$ Since A0 is specified, the rectangle is not rotated; A0 is equivalent to a simple DRAW F$. Now enter: DRAW "A1"+F$ and you have a tall rectangle. To see the full range of rotation possible with the A subcommand, leave the screen unchanged and enter: DRAW "A2"+F$ ...and ... DRAW "A3"+F$ The angle set by an angle subcommand remains in effect until you change it. To return to the normal reference axes, enter: DRAW "A0" A CLS or NEW command also resets the angle to 0. The TA subcommand does essentially what the A subcommand does, only better. The TA subcommand lets you rotate the reference axes for the DRAW statement by any multiple of 1 degree, clockwise or counter- clockwise, from the standard orientation. The TA command is given as: DRAW "TAn" where n is an angle, expressed in degrees between 0 and 360, by which the reference axes are to be rotated. "TA90" is the same as "A1". "n" may be prefixed by a plus or minus sign; a plus sign indicates counterclockwise rotation, and a minus sign indicates clockwise rotation. Counterclockwise rotation is the default. If you are using a version of BASIC later than 2.0, clear the screen and enter: T$="U50 R60 D50 L60" Then clear the screen again and enter: DRAW "TA30"+T$+"TA120"+T$+"TA210"+T$+"TA300"+T$ to try another four-way rotation of a rectangle using different angles. To get a better feel for what the TA subcommand can do, use the key to return to the line the DRAW statement is on (don't clear the screen), edit the line to read: DRAW "TA45"+T$+"TA135"+T$+"TA225"+T$+"TA315"+T$ and press . Edit this line four times to enter each of the following commands: DRAW "TA60"+T$+"TA150"+T$+"TA240"+T$+"TA330"+T$ DRAW "TA75"+T$+"TA165"+T$+"TA255"+T$+"TA345"+T$ DRAW "TA90"+T$+"TA180"+T$+"TA270"+T$+"TA360"+T$ DRAW "TA105"+T$+"TA195"+T$+"TA285"+T$+"TA15"+T$ Enter: DRAW "TA0" to reset the reference axes to the normal state. The horizontal distance between pixels on the screen differs slightly from the vertical distance; in medium-resolution mode 5 vertical pixels cover the same distance as 6 horizontal pixels. The relationship between x and y distances is known as the screen aspect ration. In medium-resolution mode, the, the aspect ration is 5/6; in high-resolution mode it is 5/12, meaning that 12 horizontal pixels span the same distance as 5 vertical pixels. The angle subcommands correct for screen aspect ratio each time a form is rotated, so that figures retain their original dimensions no matter how they're rotated. The Paint Subcommand The P subcommand is actually the familiar PAINT statement in a new setting. It provides a neat and easy way to color an image, filling in an area with a solid color until a boundary color is reached. Like the TA subcommand, however, the P subcommand is provided only by BASIC 2.0 and later versions. The P subcommand syntax is: DRAW "Pp,b" where p is the paint color and b is the color of the boundary at which painting is to stop. Both parameters are required. If you set p out of range, it defaults to the current color, while an out-of-range b defaults to the p color. Like most DRAW subcommands, P starts its action at the LPR. The LPR is not changed by the P subcommand. If you are using a BASIC version later than 2.0, clear the screen and enter: DRAW "BM160,100 D50 R10 U5 R30 D10 R5 U50 M160,100 BF5 P1,3" to draw and fill in an irregular form. Teh P subcommand has a quirk shared by all forms of painting in BASIC: painting stops at horizontal lines of the paint color. For a demonstration, clear the screen in medium-resolution mode and enter: LINE (110,100)-(210,100),1 CIRCLE (160,100),40,2 DRAW "BM170,110 P1,2" The painting stops at the horizontal cyan line (color 1), although the specified boundary color is magenta (color 2). Painting affects the color used by DRAW; when P finishes, the paint color becomes the DRAW color. Enter: DRAW "L150" to see that the DRAW color changes to color 1, cyan, after the previous Paint example executes. The DRAW Language As you can see, the DRAW statement is really a small graphics- oriented language. The subcommands are few, and their effects are confined to graphics, but the DRAW statement is compact, powerful, and self-contained. DRAW is one of the primary reasons that BASICA is considered an exceptional graphics language. As your graphics projects become more ambitious, you'll probably find that the DRAW statement plays an increasingly prominent role. You can develop a set of primitives -- DRAW command strings that define frequently used building-block forms -- to use in many programs. Whenever you consider how to approach a graphics problem, think of DRAW. As your programs become larger, space considerations will assume new importance, and there is no more compact way to perform graphics than with the DRAW statement. Putting DRAW to Work (PC World August 1985 by Karl Koessel) Using the line and bar graphing program below is simple and straightforward. The program first asks you to enter a label for the x-axis, another for the y-axis, and finally your data. After giving you an opportunity to correct your entries, it plots a line graph. Instructions to "Press B, C, L, or " appear at the screen's upper right. Touch B and the line graph becomes a bar graph; pressing L does the reverse; C gives you another opportunity to change or add to the data; and ends the program. Most of the code is devoted to data input and correction, with a few lines for bells and whistles: lines 840 through 890 center the labels; lines 150 and 160 ensure that is on; and, just before the program ends, line 60 resets to its initial state. But of primary interest are the routines that use the DRAW statement. Both the line graphing routine finish with a call to the routine that draws the x- and y-axes. The axes routine (line 800) contains the simplest DRAW statement. The movement subcommand "BM20,190" causes a "blank move" to the screen coordinates 20,190 -- a spot near the screen's lower left corner. Without altering the screen image, that location, which is to be the graph's origin, becomes the last point referenced (LPR). Next, "C3" sets the drawing color, and "NU180" draws a line (the y-axis) up 180 pixels without changing the LPR. The next movement subcomamnd is "R295", which draws a line (the x-axis) from the unchanged LPR (20,190) 295 pixels to the right. The completed axes define a plotting area of 295 by 180 pixels with the original 20,190. To draw a line graph, we need to determine the screen coordinates of each data point and the horizontal distance between points. To draw a bar graph, we need to know each bar's length and width. The horizontal spacing of the points in the line graph and the width of the bars in the bar graph are equal to the largest integer less than or equal to the value of the length, in pixels, of the x-axis, divided by the number of values to be plotted. Line 440 calculates that width using integer division (\) and stores its value in the variable HINC (horizontal increment). After the largest value has been determined and stored in the variable LARGESTY (lines 450 through 480), the length of each bar (YB(I)) is calculated as a percentage of the 180-pixel y-axis length (lines 490 through 510). The percentage is based on the ration of the particular data value divided by LARGESTY. The length of the bar is used to determine the placement above the x-axis of each point in the line graph. After setting the first x-coordinate value equal to half the horizontal distance between points (line 550) in order to position the first point to the right of the x-axis, we are ready to draw the line graph. Line 560 issues a blank move to the first point. That line demonstrates the DRAW statement used with variables instead of "hard coded" values, such as the coordinates, color values, and movement distances specified in line 800. Variables may be included in DRAW statement movement subcommands in two ways. For example, the statement DRAW "U=X;" will draw a line up X pixels, and the statement DRAW "U="+VARPTR$(X) will do the same. Because the IBM BASIC Compiler supports only the latter method, that syntax is used throughout the program. Lines 570 through 600 increment the x-coordinate and DRAW a line in color 2 from the LPR to the next point, using variables to determine the next point's coordinates. To begin DRAWing the bar graph, line 650 resets the LPR to the graph origin. Then, using the variable syntax, lines 660 through 760 DRAW and color each bar. Line 680 DRAWs a blank right move of one bar width along the x-axis if the bar's length is zero or less and then sends the program to DRAW the next bar. Lines 690 through 710 DRAW a line, in color 3, up to the point at the appropriate distance above the x-axis, right one bar width, and back down to the x-axis. Line 720 then completes the bar without changing the LPR, which is now at the lower right corner of the bar. Next, line 730 makes a blank move into the bar, and line 740 paints the bar with one of the four colors available in medium resolution. (Note that the DRAW statement does not support using variables for the P subcommand.) Then a blank move is made back to the lower right corner of that bar, and the next bar is drawn and colored. You can spruce up the graphs by adding a few extra DRAW statements. Try removing the "R295" from the end of the string of DRAW statement movement subcommands in line 800 and adding the following lines: 801 X=HINC/2:DRAW "R="+VARPTR$(X)+"NU5" 802 FOR I=1 TO N 803 DRAW "R="+VARPTR$(HINC)+"NU5" 804 NEXT Can you tell what effect those lines will have? You might also add these lines: 565 DRAW "C1NM20,="+VARPTR$(YL(1)) 595 DRAW "C1NM20,="+VARPTR$(YL(I)) or the lines: 565 DRAW "C1 BU1 F2 G2 H2 E2 BD1" 595 DRAW "C1 BU1 F2 G2 H2 E2 BD1" to emphasize the value of each point. Clearly, the DRAW statement can be much more than a programming exercise. If the exploding pie charts of fancy business graphics packages are too expensive, DRAW your own conclusions. 10 GOSUB 130 20 GOSUB 190 30 GOSUB 340 40 GOSUB 540 50 X$=INPUT$(1) 60 IF X$=CHR$(27) THEN POKE 7,KBS:GOTO 110 70 IF X$="C" OR X$="c" THEN GOTO 30 80 IF X$="L" OR X$="l" THEN GOSUB 540 90 IF X$="B" OR X$="b" THEN GOSUB 640 100 GOTO 50 110 LOCATE 3,1:END 120 'Initialize program 130 DEFINT A-X 140 DIM Y$(300),Y(300),YL(300),YB(300) 150 DEF SEG=&H41:KBS=PEEK(7) 160 POKE 7,KBS OR 32 170 RETURN 180 'Input labels & data 190 CLS:KEY OFF:SCREEN 0,0,0,0:WIDTH 80:COLOR 7,0 200 LOCATE 1,30:PRINT "Line and Bar Graphs" 210 PRINT 220 PRINT "Labels can include spaces." 230 INPUT "Enter x-axis label (up to 35 characters): ",XAXIS$ 240 INPUT "Enter y-axis label (up to 20 characters): ",YAXIS$ 250 XAXIS$=LEFT$(XAXIS$,35):YAXIS$=LEFT$(YAXIS$,20) 260 PRINT "Enter the value for each point (or Q to quit)" 270 PRINT "Point Value" 280 IF N<147 THEN N=N+1 ELSE 320 290 X=N:GOSUB 920 300 IF LEFT$(Y$(X),1)<>"q" AND LEFT$(Y$(X),1)<>"Q" THEN 280 310 Y$(X)="":N=N-1 320 RETURN 330 'Verigy or change data 340 SCREEN 0,0:WIDTH 80 350 FOR I=1 TO N+1 STEP 20 360 CLS:PRINT "Point Value":PRINT 370 FOR J=I TO I+20 380 PRINT USING "###";J;:PRINT SPC(11);Y(J) 390 NEXT 400 LOCATE 23,1:PRINT "Do you want to change any of these values (y/n)? "; 410 X$=INPUT$(1):IF X$="y" OR X$="Y" THEN GOSUB 970 420 IF X$<>"n" AND X$<>"N" THEN 400 430 NEXT 440 HINC=295\N 450 LARGESTY=0 460 FOR K=1 TO N 470 IF Y(K)>LARGESTY THEN LARGESTY=Y(K) 480 NEXT 490 FOR I=1 TO N 500 YB(I)=Y(I)/LARGESTY*180:YL(I)=190-YB(I) 510 NEXT 520 RETURN 530 'Draw line graph 540 CLS:SCREEN 1,0:COLOR 9,0 550 X=20+HINC/2 560 DRAW "BM="+VARPTR$(X)+",="+VARPTR$(YL(1)) 570 FOR I=2 TO N 580 X=X+HINC 590 DRAW "C2 M="+VARPTR$(X)+",="+VARPTR$(YL(I)) 600 NEXT 610 GOSUB 800 620 RETURN 50 630 'Draw bar graph 640 CLS:SCREEN 1,0:COLOR 9,0 650 DRAW "BM20,190" 660 FOR I=1 TO N 670 IF Y(I)>0 THEN 690 680 DRAW "BR="+VARPTR$(HINC):GOTO 760 690 DRAW "C3 U="+VARPTR$(YB(I)) 700 DRAW "R="+VARPTR$(HINC) 710 DRAW "D="+VARPTR$(YB(I)) 720 DRAW "NL="+VARPTR$(HINC) 730 DRAW "BM-1,-1" 740 DRAW "P"+STR$(I MOD 4)+",3" 750 DRAW "BM+1,+1" 760 NEXT 770 GOSUB 800 780 RETURN 50 790 'Draw axes and print labels 800 DRAW "BM20,190 C3 NU180 R295" 810 LOCATE 1,1 820 PRINT "Largest value ---- Press B,C,L, or "; 830 PRINT STR$(LARGESTY) 840 LENYAXIS=LEN(YAXIS$) 850 FOR I=1 TO LENYAXIS 860 LOCATE (25-LENYAXIS)/2+I,1 870 PRINT MID$(YAXIS$,I,1); 880 NEXT 890 LOCATE 25,(44-LEN(XAXIS$))/2:PRINT XAXIS$; 900 RETURN 910 'Input new data 920 PRINT USING "### ";X;:INPUT;"",Y$(X) 930 IF Y$(X)="" THEN PRINT Y(X):GOTO 950 940 PRINT:Y(X)=VAL(Y$(X)) 950 RETURN 960 'Change a value 970 GOSUB 1030:INPUT;"Change value of which point";X 980 IF XI+20 THEN 970 ELSE IF X>N THEN N=X 990 LOCATE 3+(X-1) MOD 20:GOSUB 1030 1000 GOSUB 920 1010 RETURN 1020 'Erase current line of text 1030 LOCATE ,1:PRINT SPACE$(79); 1040 LOCATE ,1 1050 RETURN