Compucolor.org – Virtual Media

Listing of file='PLOT.BAS;01' on disk='vmedia/statistics_1-sector.ccvf'

5 REM  PLOT
10 REM  WRITTEN BY WALTER DEGLER 2/9/79
12 REM  DRAWS 1 TO 3 GRAPHS ON A CARTESIAN COORDINATE SYSTEM.
14 REM
16 REM  XS,YS-STARTING SCALE VALUES
17 REM  XE,YE-ENDING SCALE VALUES
18 REM  XD,YD-CONSTANT SCALE DIFFERENCES
19 REM  XI,YI-SCALE PLOT INTERVAL (CHARACTER POSITIONS)
22 REM  XS(I),YS(I)-SCALE VALUES
23 REM  XN,YN-NUMBER OF SCALE DIVISIONS
24 REM  Z$-"X" IF DATA SOURCE IS A FILE
25 REM
26 PLOT 27,24,14,6,2,12
30 DIM XS(7),YS(13)
35 DIM F$(2),T1(2),T2(2)
50 A= .0001:GOSUB 8999:IF A< > .0001THEN 2000
70 GOSUB 10000:REM  SELECT DATA SOURCE
72 IF Z$= "X"THEN 2000
75 GOTO 3000
210 IF Z$= "X"THEN GOSUB 11000:GOTO 8400
225 GOTO 8000
250 REM
2000 REM  ENTER SCALE DATA
2005 PRINT
2010 PLOT 6,1
2025 INPUT "GRAPH NAME: ";G$
2030 INPUT "X-SCALE NAME, Y-SCALE NAME: ";X$,Y$
2033 PLOT 6,6
2035 PRINT
2050 INPUT "X-SCALE (START, END, DIFFERENCE): ";XS,XE,XD
2075 INPUT "Y-SCALE (START, END, DIFFERENCE): ";YS,YE,YD
2080 IF Z$= "X"THEN 2110
2090 PLOT 6,3
2100 INPUT "NUMBER OF GRAPHS (1,2 OR 3): ";N
2105 PRINT
2110 PLOT 12,15,6,2
2275 GOTO 6000
2999 REM
3000 REM  ENTER FORMULAE
3010 PLOT 6,2
3025 PRINT "ENTER FORMULAS IN 'BASIC' NOTATION USING THE FOLLOWING"
3050 PRINT "LINE NUMBERS AND VARIABLE NAMES (FOLLOWED BY 'RUN'):"
3060 PLOT 6,3
3075 PRINT "9000A=FN(B)  (FIRST EQUATION TO GRAPH)"
3100 PRINT "9100C=FN(D)  (SECOND EQUATION TO GRAPH (OMIT IF NONE))"
3125 PRINT "9200E=FN(F)  (THIRD EQUATION TO GRAPH (OMIT IF NONE))"
3200 PLOT 6,6
3225 PRINT "EXAMPLE:"
3250 PRINT "9000A=4*B-2"
3300 PRINT "RUN"
3325 PLOT 6,2
3350 END
3999 REM
4000 REM  DRAW BOX
4010 PLOT 6,4
4025 I= 2* (10+ XI* (XN- 1))
4050 J= 17+ 4* YI* (YN- 1)
4075 PLOT 2,17,15
4100 PLOT 242,I,15,I,J,17,J,17,15
4125 PLOT 255
4999 REM
5000 REM  PRINT NAMES
5010 PLOT 6,6
5025 PLOT 3,INT ((64- LEN (G$))/ 2),0:PRINT G$
5050 PLOT 27,10
5075 PLOT 3,0,2+ INT ((26- LEN (Y$))/ 2):PRINT Y$
5100 PLOT 27,24
5125 PLOT 3,7+ INT ((56- LEN (X$))/ 2),30:PRINT X$
5130 PLOT 6,2
5150 GOTO 210
5999 REM
6000 REM  COMPUTE POSITIONS OF MARKS AND PLOT TICKS
6005 PLOT 6,4
6010 XN= INT ((XE- XS)/ XD)+ 1:IF XN> 8THEN XN= 8
6020 YN= INT ((YE- YS)/ YD)+ 1:IF YN> 14THEN YN= 14
6025 XI= INT (49/ (XN- 1))
6050 YI= INT (26/ (YN- 1))
6075 IF XI< 7THEN XI= 7
6100 IF YI< 1THEN YI= 1
6125 FOR I= 0TO XN- 1
6150 PLOT 2,2* (9+ I* XI),14,255
6175 NEXT
6200 FOR I= 0TO YN- 1
6225 PLOT 2,16,16+ 4* I* YI,255
6250 NEXT
6999 REM
7000 REM  COMPUTE AND PLOT SCALE VALUES
7010 PLOT 6,3
7050 FOR I= 0TO XN- 1
7075 XS(I)= XS+ I* XD
7200 PLOT 3,8+ I* XI,29:PRINT XS(I)
7225 NEXT
7325 FOR I= 0TO YN- 1
7330 LY= LEN (STR$ (YS+ I* YD))
7350 YS(I)= YS+ I* YD
7475 PLOT 3,7- LY,27- I* YI:PRINT YS(I)
7500 NEXT
7525 GOTO 4000
7999 REM
8000 REM  PLOT GRAPH(S)
8025 FOR K= 0TO N- 1
8050 FOR I= 0TO 2* XI* (XN- 1)
8100 X= XS+ I* XD/ (XI+ XI)
8110 IF X> XETHEN 8350
8125 ON KGOTO 8175,8200
8150 B= X:GOSUB 9000:Y= A:PLOT 6,6:GOTO 8225
8175 D= X:GOSUB 9100:Y= C:PLOT 6,3:GOTO 8225
8200 F= X:GOSUB 9200:Y= E:PLOT 6,1
8225 IF Y< YSOR Y> YS+ YD* (YN- 1)THEN 8325
8250 XP= 18+ I
8275 YP= 16+ 4* YI* (Y- YS)/ YD
8300 PLOT 2,XP,YP,255
8325 NEXT I
8350 NEXT K
8400 PLOT 6,1,3,0,31
8450 INPUT "ENTER 1-NEW SCALES, 2-SAVE OR 3-END: ";X
8475 IF X= 1THEN PLOT 12,6,2:GOTO 2050
8500 IF X< > 2THEN LOAD "MENU":RUN
8525 PLOT 27,4:PRINT "SAVE PLOT.DSP 6000 1000":PLOT 27,27
8550 PLOT 12
8575 INPUT "ENTER 1-NEW SCALES OR 2-END: ";X
8580 PLOT 12
8600 IF X= 1THEN PLOT 6,2:GOTO 2050
8625 LOAD "MENU":RUN
8999 REM  FORMULAS FOLLOW
9025 RETURN
9325 RETURN
9999 REM
10000 REM  SELECT DATA SOURCE
10010 PLOT 6,1
10025 INPUT "DATA SOURCE: 1-EQUATION OR 2-FILE ";Z
10050 IF Z= 1THEN RETURN
10075 IF Z< > 2THEN 10025
10080 PLOT 6,3
10100 INPUT "NUMBER OF GRAPHS: ";N
10105 PRINT
10110 PLOT 6,2
10125 FOR I= 0TO N- 1
10150 PRINT "FILE NAME "I+ 1" AND TYPE NUMBERS ";:INPUT F$(I),T1(I),T2(I)
10175 NEXT
10200 Z$= "X"
10225 RETURN
10999 REM
11000 REM  PLOT FILE DATA POINTS
11025 FOR I= 0TO N- 1
11050 K= 6- 3* I:IF K= 0THEN K= 1
11075 PLOT 6,K
11100 FILE "R",1,F$(I),4
11125 GET 1,1,1;NT,NO
11150 FOR J= 0TO NO- 1
11175 GET 1,T1(I),9+ 4* J;X
11200 GET 1,T2(I),9+ 4* J;Y
11225 IF X< XSOR X> XS+ XD* (XN- 1)THEN 11350
11250 IF Y< YSOR Y> YS+ YD* (YN- 1)THEN 11350
11275 XP= 18+ 2* XI* (X- XS)/ XD
11300 YP= 16+ 4* YI* (Y- YS)/ YD
11325 PLOT 2,XP,YP,255
11350 NEXT J
11375 FILE "C",1
11400 NEXT
11425 RETURN