I want to use the CRT unit in some Pascal code, just for the "clrscr" function but it's causing issues. The code compiles fine, but then some text is out of place and symbols appear where they shouldn't.
Here is the code:
program fuel(input, output);
var
i,vnumber:integer;
f,f2:text;
volfuel,dist,totalfuel,totaldist:double;
ch:char;
s,z:string;
begin
assign(f,'fuel.txt');
assign(f2,'report.txt');
{$i-}
reset(f);
rewrite(f2);
{$i+}
if ioresult<>0 then halt;
totalfuel:=0;
totaldist:=0;
s:='~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~';
writeln(s);
writeln(f2,s);
z:='Vehicle No.'+#9+'Fuel Consumption (MPG)';
writeln(z);
writeln(f2,z);
writeln(s);
writeln(f2,s);
while not eof(f) do
begin
read(f,vnumber);
read(f,ch);
read(f,volfuel);
read(f,ch);
read(f,dist);
readln(f);
totalfuel:=totalfuel+volfuel;
totaldist:=totaldist+dist;
writeln(vnumber,#9,(dist/volfuel):15:2);
writeln(f2,vnumber,#9,(dist/volfuel):15:2);
end;
writeln(s);
writeln(f2,s);
z:='~~~~~~~~~~~~~~~~~~~~SUMMARY~~~~~~~~~~~~~~~~~~~~~~~~';
writeln(z);
writeln(f2,z);
writeln(s);
writeln(f2,s);
writeln('Total Gallons = ',totalfuel:10:2);
writeln(f2,'Total Gallons = ',totalfuel:10:2);
writeln('Mean Petrol Consumption = ',totaldist/totalfuel:10:2);
writeln(f2,'Mean Petrol Consumption = ',totaldist/totalfuel:10:2);
close(f);
close(f2);
readln;
end.
As soon as I add "uses crt;" that's when I get problems. It's not just happened with this Pascal program either, I few I have done and then wanted to add "clrscr" or some colour, I can't as when I add CRT, it causes spacing/formatting problems.
Any help would be great!