8-Bit Software Online Conversion
:2.$.MPG2 - Listing
10REM MPG2&Lp100Km Calculator
20REM By W.E.Jowitt K2V
30MODE129
40 *FX16
50 a=0
60 del$=STRING$(33," ")
70DIM mpg(10),d(10),m(10),y(10)
80 h$=CHR$(17)+CHR$(129)+" * Petrol C
onsumption *"+CHR$(17)+CHR$(128)
90PRINT'SPC(6)h$'
100PRINT'"Quantity entered taken as li
tres"'" unless gallons (G/g) entered."
110REM LOAD mpgs
120COLOUR 2
130PRINT'"Load previous MPG file?(Y/N)
";
140IF INSTR("Yy",GET$)GOTO 160 ELSE PR
INT'"Car Registration Number "
150PROCINPUT(7):GOTO320
160MODE 134
170PRINT''"Car Registration Number":PR
OCINPUT(7)
180file=OPENIN C$
190FOR i=1 TO 10
200INPUT #file,mpg(i)
210INPUT #file,d(i)
220INPUT #file,m(i)
230INPUT #file,y(i)
240NEXT
250INPUT #file,b
260CLOSE #file
270IF b>1000 THEN b=b-1000
280a=b
290MODE 1
300PRINT'SPC(6)h$'
310REM New mpg
320COLOUR 3
330PRINT'"Calculate new MPG (Y/N)?"
340IF INSTR("Yy",GET$) ELSE 680
350FOR i=10 TO 2 STEP -1
360mpg(i)=mpg(i-1)
370m(i)=m(i-1)
380d(i)=d(i-1)
390y(i)=y(i-1)
400NEXT
410IF a=0 THENINPUT'"Milage at previou
s fill? "a:GOTO430
420PRINT'"Milage at previous fill
";a
430INPUT'"Milage at this fill up ?
"b
440 PRINT
450INPUT"Date of fill (day no.) ?
"d
460IF d>31 THEN VDU11:PRINTdel$:VDU11:
GOTO450
470PRINT
480INPUT"Month (month no.) ?
"m
490IF m>12 THEN VDU11:PRINTdel$:VDU11:
GOTO480
500INPUT'"Year ?
19"y
510IF a>b THEN b=b+1000
520k=b-a
530PRINT'"Miles since last fill
";k
540INPUT'"How much petrol filled ?
"p$
550@%=&20205
560p=VALp$
570IF (ASC(RIGHT$(p$,1))OR 32)=ASC"g"T
HEN 580 ELSE p=p/4.546
580mpg(1)= (k/p)
590d(1)=d
600m(1)=m
610y(1)=y
620COLOUR 2
630 PRINT'" MPG = ";mpg(i);" L/100Km
= ";282.47/mpg(i)
640@%=&00304
650COLOUR 1
660PRINT'"Hit a key...";
670G%=GET
680REM Bar chart
690CLS:COLOUR 2
700 PRINT''TAB(4)h$;CHR$(17)+CHR$(129)
+" "+C$+" * "+CHR$(17)+CHR$(128)
710PRINT'"MPG L/100Km";TAB(27)"L/100Km
";TAB(36)"MPG"
720@%=&20204
730PRINT " "
740FOR i=10 TO 1 STEP-1
750IF mpg(i)=0 THEN k=0 :GOTO 754
752k=282.47/mpg(i)
754IF k<10 THEN r=30 ELSE r=29
760PRINTTAB(r);k;TAB(35);mpg(i)
770NEXT
780x=12
790 VDU29,120;200;
800@%=&00304
810FOR j=10 TO 50 STEP 2
820MOVE 0,x*j:PLOT21,800,x*j
830NEXT
840GCOL0,1
850FOR h=5 TO 50 STEP 5
860MOVE 0,x*h:PLOT21,800,x*h
870NEXT
880PRINTTAB(0,26)"DATE"
890PRINTTAB(0,27)"MONTH"
900PRINTTAB(0,28)"YEAR"
910COLOUR 3
920FOR i=1 TO 10
925y=11-i
930IF mpg(i) ELSE 980
940GCOL 1,1
950 MOVE 72*y,x*mpg(i):MOVE 72*y+64,x*
mpg(i):PLOT 85,72*y,4:PLOT 85,72*y+64,4
960GCOL 0,3
970 MOVE 72*y,4:DRAW 72*y,x*mpg(i):DRA
W 72*y+64,x*mpg(i):DRAW 72*y+64,4
980 VDU5:MOVE -82,12+x*i*10:IF i*10>50
GOTO 990 ELSE PRINT;i*10;SPC(1)INT(28/i
)
990 MOVE 72*y,-12:IF d(i)<10PRINT" ";
992 PRINT;d(i);
1000 MOVE 72*y,-46:IFm(i)<10PRINT" ";
1002PRINT;m(i);
1010 MOVE 72*y,-80:PRINT;y(i);
1020VDU4
1030NEXT
1040MOVE 0,600:DRAW 0,0:DRAW 800,0
1050PRINT'" Press any key for SAVE or
EXIT."
1060G%=GET
1070REM SAVE mpgs
1080MODE 6
1090PRINT''" SAVE ";C$;" mpg's ? (Y/N)"
;
1100IF INSTR("Yy",GET$) THEN PRINT" Y"
ELSE PRINT" N":GOTO 1200
1110file=OPENOUT C$
1120FOR i=1 TO 10
1130PRINT #file,mpg(i)
1140PRINT #file,d(i)
1150PRINT #file,m(i)
1160PRINT #file,y(i)
1170NEXT
1180PRINT #file,b
1190CLOSE #file
1200PRINT''" For repeat press R"''" Pre
ss SPACE for MENU"
1205 G=GET:IF G=32 CHAIN"MENU"
1208 IF G=82 GOTO270
1210DEFPROCINPUT(X)
1220C$=""
1230FOR T=1TOX+1
1240K=GET
1250IFK=127ANDT>1THENT=T-1:VDU127:C$=LE
FT$(C$,T-1):GOTO1240
1260IFK=13THENT=X+1:GOTO1310
1270IFK<>13ANDT=X+1THEN1240
1280IFK<32 OR K>126THEN1240
1290C$=C$+CHR$(K)
1300VDUK
1310NEXT:ENDPROC