can any one help with a delete procedure please. it is AS coursework and i cant get it to work it compiles but gives a run time error.
begin
clrscr;
assign (pupilfile,'n:pupil.dat');
reset (pupilfile);
writeln ('existing file');
writeln;writeln;writeln;
writeln ('name':15,' Candidate':9,'year':6,'mark':5);
writeln (' ':15,' number ':9,' ':6,' ':5);
writeln;
writeln;
readln;
while not eof (pupilfile) do
begin
read (pupilfile,temp);
writeln (temp.name:15,temp.cand_no:9,temp.year:6,temp.mark:5);
end;
reset (pupilfile);
writeln ('enter candidate number to be deleted');
readln (n);
position:=0;
while not eof (pupilfile) do
begin
read (pupilfile,temp);
position:=(position+1);
if (temp.cand_no=n) then begin
clrscr;
writeln (temp.name:15,temp.cand_no:9,temp.year:6,temp.mark:5);
writeln;writeln;
writeln ('is this the record to be deleted: ');
readln (ans);
if (ans='y') or (ans='Y') then begin
seek (pupilfile,filesize(pupilfile)-1);
truncate (pupilfile);
end;
reset (pupilfile);
clrscr;
writeln ('name':15,'year':10,'mark':10);
writeln;
while not eof (pupilfile) do
begin
read (pupilfile,temp);
writeln (temp.name:15,temp.cand_no:8,temp.year:6,temp.mark:5);
end;
close (pupilfile);
end;
end;
??????????????????????????????? thanks for your help...