HI
I'm making this program and out of the blue , without having changed
anything this error came up when I wanted to run it ... Could you
please help??
Here's the program although the load and save procedures are not ready
yet so don't bother with them .
I'm suspecting that a procedure named "closetoV" is responsible for
this because it's dealing with a quadratic but I can't seem to find the
problem. I read about runtime error 207 and it is supposed to point at
a number too big for round to round it . But it's not that because the
number is simply not that big ... Any ideas .. Thanks anyway ...
NoViE
Here it is ... Take a look at it ... It's written in Turbo Pascal for
DOS
program tryopenf;
uses Crt,Graph;
const cMaxnum = 10;
sPath : string='';
max = 10;
type rNumbers = record
question : string;
answer : real;
end;
var fSimData : file of rNumbers;
aFilename : array [1..max] of string;
anumber : array [1..cMaxnum] of rNumbers;
gd,gm,gerror : integer;
choiceB : char;
procedure simquestions;
var I:integer;
begin
for I:=1 to cMaxnum do
begin
if I=1 then
begin
repeat
begin
clrscr;
writeln (aNumber[I].question);
readln (aNumber[I].answer);
end
until (aNumber[I].answer=1.0) or (aNumber
[I].answer=2.0) or (aNumber[I].answer=3.0);
end
else
begin
if I in [2,3] then
begin
repeat
begin
clrscr;
writeln (aNumber[I].question);
readln (aNumber[I].answer);
end
until (aNumber[I].answer=1.0) or
(aNumber[I].answer=2);
end
else
begin
clrscr;
writeln (aNumber[I].question);
readln (aNumber[I].answer);
end;
end;
end;
writeln('press any key to continue...');
readkey;
end;
procedure recload;
begin
aNumber[1].question:='Analysis: press [a] for m/pixel or [b]
for cm/pixel or [c] for Km/pixel';
aNumber[2].question:='Type of collision: press [a] for elastic
or [b] for inelastic';
aNumber[3].question:='Type of motion: press [a] for uniform or
[b] for uniformly accelerated';
aNumber[4].question:='Give the mass of the first object in Kg';
aNumber[5].question:='Give the mass of the second object in Kg';
{aSimB[3].question:='Give the coefficient of friction '};
aNumber[6].question:='Give the velocity of the first object
before the collision';
aNumber[7].question:='Give the velocity of the second object
before the collision';
aNumber[8].question:='Give the distance of first object from
point of reference';
aNumber[9].question:='Give the distance of second object from
point of reference';
aNumber[10].question:='Give the distance of the point of
reference from the left end of the screen';
{aSimB[8].question:='Give the distance of first object from
point of collision after the collision';
aSimB[9].question:='Give the distance of second object from
point of collision after the collision';}
end;
procedure load;
var line:string[80];
tText:text;
begin
assign (tText,'a:\dearuser');
reset(tText);
while not eof(tText) do
begin
readln (tText,line);
writeln (line);
end;
readkey;
clrscr;
end;
function EI(MA,MB,VAI,VBI:real):real;
begin
EI:=((MA*VAI*VAI)/2)+((MB*VBI*VBI)/2);
end;
function MI (MA,MB,VAI,VBI:real):real;
begin
MI:=(ma*VAI)+(mb*VBI);
end;
function C (MA,MB,VAI,VBI:real):real;
begin
C:=-EI(MA,MB,VAI,VBI)+(MI(MA,MB,VAI,VBI)*MI
(MA,MB,VAI,VBI)/(2*MB));
end;
Function B(MA,MB,VAI,VBI:real):real;
begin
B:=MI(MA,MB,VAI,VBI)*MA/MB;
end;
function A(ma,mb:real):real;
begin
A:=(ma/2)+(mA*mA/(2*mB));
end;
procedure closetoV (var MA,MB,VAI,VBI,VAF,VBF:real);
var D,E,VAFa,VAFb,VBFa,VBFb:real;
begin
D:=B(MA,MB,VAI,VBI)*B(MA,MB,VAI,VBI)-4*A(MA,MB)*C
(MA,MB,VAI,VBI);
if D<0 then
begin
writeln ('according to the data you have given the two
objects never collide...')
end
else
begin
if D=0 then
begin
VAF:=(-B(MA,MB,VAI,VBI))/(2*A(MA,MB));
VBF:=(MI(MA,MB,VAI,VBI)-(MA*VAF))/MB;
end
else
begin
E:=sqrt(D);
VAFa:=(-B(MA,MB,VAI,VBI)+E)/(2*A(MA,MB));
VAFb:=(-B(MA,MB,VAI,VBI)-E)/(2*A(MA,MB));
VBFa:=(MI(MA,MB,VAI,VBI)-(ma*VAFa))/mb;
VBFb:= (MI(MA,MB,VAI,VBI)-(ma*VAFb))/mb;
if (VBFa=VBI) and (VAFa=VAI) then
begin
if (VBFb<>VBI) and (VAFb<>VAI) then
begin
VBF:=VBFb;
VAF:=VAFb;
end;
end
else
if (VBFb=VBI) and (VAFb=VAI) then
begin
VBF:=VBFa;
VAF:=VAFa;
end;
end;
end;
end;
procedure drawcircle(var rX,rVelocity:real);
var wRadius:word;
iMaxY:integer;
begin
wRadius:=10;
iMaxY:=getmaxY;
circle(round(rX),iMaxY div 2,1);
circle(round(rX),iMaxY div 2,wRadius);
delay(round(1000/rVelocity));
end;
procedure setwindow(xx,xy,yy,yx,color:word);
begin
window(xx,xy,yy,yx);
setbkcolor(color);
clearviewport;
end;
procedure circlemove (var rDistA,rDistB,rRef:real);
var rMovA,rMovB,VAF,VBF:real;
maxX,maxY:integer;
bKeypressed:boolean;
begin
maxX:=getmaxX;
maxY:=getmaxY;
rMovA:=rRef+rDistA;
rMovB:=rRef+rDistB;
outtext('press any key to start simulation...');
readkey;
outtextXY(1,40,'simulating...');
repeat
setwindow(1,15,80,16,0);
if rDistA-rDistB<0 then
begin
rMovA:=rMovA+1;
rMovB:=rMovB-1;
end
else
begin
rMovA:=rMovA-1;
rMovB:=rMovB+1;
end;
drawcircle(rMovA,aNumber[6].answer);
drawcircle(rMovB,aNumber[7].answer);
until abs(rMova-rMovb)=22;
outtextXY(1,80,'press any key whenever you wish to stop the
simulation..');
repeat
setwindow(1,15,80,16,0);
if rDistA-rDistB<0 then
begin
rMovA:=rMovA-1;
rMovB:=rMovB+1;
end
else
begin
rMovA:=rMovA+1;
rMovB:=rMovB-1;
end;
closetoV(aNumber[4].answer,aNumber[5].answer,aNumber
[6].answer,aNumber[7].answer,VAF,VBF);
drawcircle(rMovA,VAF);
drawcircle(rMovB,VBF);
until (rMovA=maxX) or (rMovA=0) or (rMovB=maxX) or (rMovB=0) or
(keypressed);
readkey;
outtext('press any key to exit...');
readkey;
end;
procedure pGraph;
var maxx,maxy,x:integer;
begin
repeat
gd:=detect;
initgraph(gd,gm,sPath);
gerror:=graphresult;
if gerror<>grOK then
begin
writeln('Graphics Error:',Grapherrormsg(gerror));
if gerror=GrFileNotFound then
begin
writeln ('Cannot find graphics driver .
Please');
write ('Enter directory path for the
driver:');
readln (sPath);
writeln;
end
else halt(1)
end
until gerror=grok;
circlemove(aNumber[8].answer,aNumber[9].answer,aNumber
[10].answer);
closegraph;
end;
procedure pSave (sFilename:string);
var loop:integer;
begin
assign (fSimData,'sFilename');
rewrite (fSimData);
for loop:=1 to cMaxNum do
begin
write (fSimData,aNumber[loop]);
close (fSimData);
end;
end;
procedure save;
var loop,iLoop: Integer;
choice: char;
sPath : string;
bnamefound:boolean;
begin
loop:=0;
writeln ('Type in the path and the name of the file ...');
writeln ('It must be given in the form a:\dir1\dir2\name.dat');
repeat
loop:=loop+1
until (loop=max) or (aFilename[loop]='');
If afilename[loop]='' then
begin
readln(aFilename[loop]) ;
pSave(aFilename[loop]);
end;
If (loop=max) and (aFilename[max]<>'') then
writeln ('This program does not handle more than ',max,'
files.');
writeln ('It
...