8-Bit Software Online Conversion
:2.$.MPG - Listing
10REM MPG2&Lp100Km Calculator
20REM By W.E.Jowitt (K2V)
30MODE1
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 to be
litres"'" unless gallons (G or g) enter
ed."
110REM LOAD mpgs
120COLOUR 2
130PRINT'"Load previous MPG file?";
140IF INSTR("Yy",GET$)GOTO 160 ELSE PR
INT'"Car Registration Number "
150PROCINPUT(7):GOTO320
160MODE 6
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@%=&20200
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@%=&20200
730PRINT " "
740FOR i=1 TO 10 STEP1
750IF mpg(i)=0 THEN 800
760k=282.47/mpg(i)
770IF k<10 THEN r=30 ELSE r=29
780PRINTTAB(r);k;TAB(35);mpg(i)
790NEXT
800x=12
810 VDU29,120;200;
820@%=&00304
830FOR j=10 TO 50 STEP 2
840MOVE 0,x*j:PLOT21,800,x*j
850NEXT
860GCOL0,1
870FOR h=5 TO 50 STEP 5
880MOVE 0,x*h:PLOT21,800,x*h
890NEXT
900PRINTTAB(0,26)"DATE"
910PRINTTAB(0,27)"MONTH"
920PRINTTAB(0,28)"YEAR"
930COLOUR 3
940FOR i=1 TO 10
950y=11-i
960IF mpg(i) ELSE 1010
970GCOL 1,1
980 MOVE 72*y,x*mpg(i):MOVE 72*y+64,x*
mpg(i):PLOT 85,72*y,4:PLOT 85,72*y+64,4
990GCOL 0,3
1000 MOVE 72*y,4:DRAW 72*y,x*mpg(i):DRA
W 72*y+64,x*mpg(i):DRAW 72*y+64,4
1010 VDU5:MOVE -82,12+x*i*10:IF i*10>50
GOTO 1020 ELSE PRINT;i;@%=&20100SPC(1)(
28/i):@%=&00301
1020 MOVE 72*y,-12:IF d(i)<10PRINT" ";
1030 PRINT;d(i);
1040 MOVE 72*y,-46:IFm(i)<10PRINT" ";
1050PRINT;m(i);
1060 MOVE 72*y,-80:PRINT;y(i);
1070VDU4
1080NEXT
1090MOVE 0,600:DRAW 0,0:DRAW 800,0
1100PRINT'" Press any key for SAVE or
EXIT."
1110G%=GET
1120REM SAVE mpgs
1130MODE 6
1140PRINT''" SAVE ";C$;" mpg's ? (Y/N)"
;
1150IF INSTR("Yy",GET$) THEN PRINT" Y"
ELSE PRINT" N":GOTO 1250
1160file=OPENOUT C$
1170FOR i=1 TO 10
1180PRINT #file,mpg(i)
1190PRINT #file,d(i)
1200PRINT #file,m(i)
1210PRINT #file,y(i)
1220NEXT
1230PRINT #file,b
1240CLOSE #file
1250PRINT''" For repeat press R"''" Pre
ss SPACE for MENU"
1260 G=GET:IF G=32 CHAIN"MPGmenu"
1270 IF G=82 GOTO270
1280DEFPROCINPUT(X)
1290C$=""
1300FOR T=1TOX+1
1310K=GET
1320IFK=127ANDT>1THENT=T-1:VDU127:C$=LE
FT$(C$,T-1):GOTO1310
1330IFK=13THENT=X+1:GOTO1380
1340IFK<>13ANDT=X+1THEN1310
1350IFK<32 OR K>126THEN1310
1360C$=C$+CHR$(K)
1370VDUK
1380NEXT:ENDPROC