10 '		KPLOT GRAPH PROGRAM
20 '
30 DIM XVAL(100): DIM YVAL(100): DIM XNEW(100): DIM YNEW(100): DIM PLOT(21,51)
40 PRINT CHR$(26)
50 PRINT "OSPLOT 1.0"
60 PRINT "created by David Ring, 12/24/82"
70 PRINT
80 PRINT
90 PRINT "This program will accept sets of X,Y data and"
100 PRINT "generate either bar graphs or unconnected X,Y"
110 PRINT "plots."
120 PRINT
130 PRINT "Your options are:"
140 PRINT
150 PRINT "	(N)  Enter a new set of X,Y points"
160 PRINT "	(D)  Display graph of data set"
170 PRINT "	(E)  Edit an existing data set"
180 PRINT "	(X)  Exit from KPLOT"
190 PRINT
200 INPUT "Your choice"; CHOICE$
210 FLAG=0
220 IF CHOICE$="N" OR CHOICE$="n" THEN GOSUB 1000
230 IF CHOICE$="D" OR CHOICE$="d" THEN GOSUB 2000
240 IF CHOICE$="E" OR CHOICE$="e" THEN GOSUB 3000
250 IF CHOICE$="X" OR CHOICE$="x" THEN END 
260 IF FLAG=1 THEN 290
270 PRINT
280 PRINT "That letter is not on the menu.  Please try again."
290 GOTO 120
1000 '**************************************************
1010 '
1020 '		SUBROUTINE TO INPUT PARAMETERS & DATA
1030 '
1040 PRINT CHR$(26)
1050 INPUT "Minimum X value"; XMIN
1060 INPUT "Maximum X value"; XMAX
1070 INPUT "Minimum Y value"; YMIN
1080 INPUT "Maximum Y value"; YMAX
1090 PRINT CHR$(26)
1100 PRINT "You may enter up to 100 X,Y pairs.  After entering"
1110 PRINT "the last pair, signal by entering the letter 'D'."
1120 PAIRS=0
1130 ' DO UNTIL X$="D" OR X$="d"
1140	PRINT
1150	INPUT "X value";X$
1160	IF X$="D" OR X$="d" THEN 1270
1170	INPUT "Y value";Y$
1180 IF VAL(X$)>XMAX OR VAL(X$)<XMIN THEN 1200 ELSE 1230
1190 IF VAL(Y$)>YMAX OR VAL(Y$)<YMIN THEN 1200 ELSE 1230
1200 PRINT
1210 PRINT "Value out of range.  Please try again."
1220 GOTO 1130
1230	XVAL(PAIRS)=VAL(X$)
1240	YVAL(PAIRS)=VAL(Y$)
1250	PAIRS=PAIRS+1
1260	GOTO 1130
1270 PAIRS=PAIRS-1
1280 GOSUB 4000  '(SUBROUTINE TO SAVE DATA FILE)
1290 FLAG=1
1300 PRINT CHR$(26)
1310 RETURN
2000 '**************************************************
2010 '
2020 '		SUBROUTINE TO DISPLAY GRAPH
2030 '
2040 PRINT CHR$(26)
2050 PRINT "You may now specify the filename of a saved data"
2060 PRINT "set to be graphed.  If you wish to use the data"
2070 PRINT "set in current memory (the last set entered or"
2080 PRINT "graphed), simply press RETURN."
2090 GOSUB 5000 '(GET SPECIFIED DATA FILE)
2100 PRINT
2110 PRINT
2120 PRINT "Please specify format for graph.  Your choices are:"
2130 PRINT
2140 PRINT "	(P)  Unconnected X,Y plot"
2150 PRINT "	(V)  Vertical bar graph"
2160 PRINT "	(H)  Horizontal bar graph"
2170 PRINT
2180 INPUT "Your choice";PLOTTYPE$
2181 PRINT CHR$(26)
2182 PRINT "Please wait.  I'm a little bit slow."
2190 BLOCK=22 '(SET CODES FOR GRAPHIC SYMBOLS)
2200 CROSS=12
2210 SQUARE=0
2220 DOT=13
2230 BORDER=BLOCK
2240 SYMBOL=SQUARE
2250 IF PLOTTYPE$="P" OR PLOTTYPE$="p" THEN 2260 ELSE 2280
2260 BORDER=CROSS
2270 SYMBOL=DOT
2280 FOR I=0 TO PAIRS '(SCALE X,Y VALUES)
2290	XNEW(I)=INT(50*(XVAL(I)-XMIN)/(XMAX-XMIN))
2300	YNEW(I)=INT(20*(YVAL(I)-YMIN)/(YMAX-YMIN))
2310	NEXT I
2320 FOR L=0 TO 20 '(FOLLOWING LOOPS DEFINE GRAPH & BORDERS)
2330	FOR M=1 TO 51
2340		PLOT(L,M)=32
2350		NEXT M
2360	PLOT(L,0)=BORDER
2370	NEXT L
2380 FOR M=0 TO 51
2390	PLOT(21,M)=BORDER
2400	NEXT M
2410 FLAG=0
2420 IF PLOTTYPE$="P" OR PLOTTYPE$="p" THEN GOSUB 6000
2430 IF PLOTTYPE$="V" OR PLOTTYPE$="v" THEN GOSUB 7000
2440 IF PLOTTYPE$="H" OR PLOTTYPE$="h" THEN GOSUB 8000          
2450 IF FLAG=1 THEN 2490
2460 PRINT
2470 PRINT "That letter is not on the menu,  Please try again."
2480 GOTO 2100
2490 PRINT CHR$(26)
2500 WIDTH 128
2510 FOR U=0 TO 21
2520	FOR V=0 TO 51
2530		PRINT CHR$(27)+"g";
2540		PRINT CHR$(PLOT(U,V));
2550		IF V=51 THEN PRINT CHR$(27)+"G"
2560		NEXT V
2570	NEXT U
2580 PRINT
2590 INPUT "Press RETURN to return to main menu.  ",DUMMY$ 
2600 FLAG=1
2610 PRINT CHR$(26)
2620 RETURN
3000 '**************************************************
3010 '
3020 '		SUBROUTINE TO EDIT DATA SET
3030 '
3040 PRINT CHR$(26)
3050 PRINT "If you wish to edit a saved data set, please"
3060 PRINT "supply file name including prefix.  If you wish"
3070 PRINT "to edit the data in current memory, press RETURN."
3080 GOSUB 5000
3090 PRINT CHR$(26)
3100 PRINT "Old minimum X value:  ";XMIN
3110 PRINT "Old maximum X value:  ";XMAX
3120 PRINT "Old minimum Y value:  ";YMIN
3130 PRINT "Old maximum Y value:  ";YMAX
3140 PRINT
3150 PRINT "If you wish to change axis parameters, enter"
3160 PRINT "new values below.  To leave a value unchanged,"
3170 PRINT "press RETURN."
3180 PRINT
3190 INPUT "New minimum X value";TEMP$
3200 IF TEMP$<>"" THEN XMIN=VAL(TEMP$)
3210 INPUT "New maximum X value";TEMP$
3220 IF TEMP$<>"" THEN XMAX=VAL(TEMP$)
3230 INPUT "New minimum Y value";TEMP$
3240 IF TEMP$<>"" THEN YMIN=VAL(TEMP$)
3250 INPUT "New maximum Y value";TEMP$
3260 IF TEMP$<>"" THEN YMAX=VAL(TEMP$)
3270 PRINT CHR$(26)
3280 PRINT "KPLOT will now display 10 X,Y points at a"
3290 PRINT "time.  To change a point, you must enter the"
3300 PRINT "number of the X,Y pair, the new X value and"
3310 PRINT "the new Y value. When through entering revised"
3320 PRINT "values, signal by entering 'D'."
3330 PRINT
3340 INPUT "Ready";DUMMY$
3350 PRINT CHR$(26)
3360 FOR A=0 TO PAIRS
3370	PRINT A, XVAL(A), YVAL(A)
3380	IF (A+1) MOD 10 = 0 OR A=PAIRS THEN 3390 ELSE 3460
3390	PRINT
3400	' DO UNTIL PAIR$="D" OR PAIR$="d"
3410		INPUT "Number of X,Y pair to revise";PAIR$
3420		IF PAIR$="D" OR PAIR$="d" THEN 3460
3430		INPUT "New X value";XVAL(VAL(PAIR$))
3440		INPUT "New Y value";YVAL(VAL(PAIR$))
3450		GOTO 3400
3460	NEXT A
3470 GOSUB 4000  '(SUBROUTINE TO SAVE DATA FILE)
3480 PRINT CHR$(26)
3490 PRINT "Editing complete.  Press RETURN to return to main" 
3500 PRINT "menu."
3510 PRINT
3520 INPUT DUMMY$
3530 FLAG=1
3540 PRINT CHR$(26)
3550 RETURN
4000 '**************************************************
4010 '
4020 '		SUBROUTINE TO SAVE DATA SET AS FILE
4030 '
4040 PRINT CHR$(26)
4050 PRINT "If you wish to save this set of X,Y data and"
4060 PRINT "axis parameters, enter a name for the file,"
4070 PRINT "including disk prefix.  Otherwise press RETURN."
4080 PRINT
4090 INPUT "Name for data file";FILENAME$
4100 IF FILENAME$="" THEN RETURN
4110 OPEN "O",#1,FILENAME$
4120 PRINT #1,PAIRS,XMIN,XMAX,YMIN,YMAX
4130 FOR J=0 TO PAIRS
4140	PRINT #1,XVAL(J),YVAL(J)  
4150	NEXT J
4160 CLOSE #1
4170 RETURN
5000 '**************************************************
5010 '
5020 '		SUBROUTINE TO READ DATA FILE
5030 '
5040 PRINT
5050 INPUT "Name of data file";FILENAME$
5060 IF FILENAME$="" THEN RETURN
5070 OPEN "I",#1,FILENAME$
5080 INPUT #1,PAIRS,XMIN,XMAX,YMIN,YMAX
5090 FOR K=0 TO PAIRS
5100	INPUT #1,XVAL(K),YVAL(K)
5110	NEXT K
5120 CLOSE #1
5130 RETURN
6000 '**************************************************
6010 '
6020 '		SUBROUTINE TO PLOT POINTS
6030 '
6040 FOR P=0 TO PAIRS
6050	PLOT((20-YNEW(P)),(XNEW(P)+1))=SYMBOL
6060	NEXT P
6070 FLAG=1
6080 RETURN
7000 '**************************************************
7010 '
7020 '		SUBROUTINE TO DRAW VERTICAL BARS
7030 '
7040 FOR P=0 TO PAIRS
7050	FOR Q=0 TO YNEW(P)
7060		PLOT((20-Q),(XNEW(P)+1))=SYMBOL
7070		NEXT Q
7080	NEXT P
7090 FLAG=1
7100 RETURN
8000 '**************************************************
8010 '
8020 '		SUBROUTINE TO DRAW HORIZONTAL BARS
8030 '
8040 FOR P=0 TO PAIRS
8050	FOR Q=0 TO XNEW(P)
8060		PLOT((20-YNEW(P)),(Q+1))=SYMBOL
8070		NEXT Q
8080	NEXT P
8090 FLAG=1
8100 RETURN
TO PAIRS
8050	FOR Q=0 TO XNEW(P)
8060		PLOT((20-YNEW(P)),(Q+1))=SYMBOL
8070		NEXT Q
8080	NEXT P
8090 FLAG=1
8100 RETU