Procedure Del_N(var f:fail); var n,i:integer; c:char; x:stud; begin write('Удалить запись № '); readln(n); reset(f); if (filesize(f)<n)or(n<0) then begin writeln('В файле нет такой записи'); close(f); write('Press Enter...'); readln; exit; end; if n=filesize(f)then begin seek(f,filesize(f)-1); truncate(f); close(f); write('Press Enter...'); readln; exit; end; seek(f,n-1); for i:=n-1 to filesize(f)-2 do begin seek(f,i+1); read(f,x); seek(f,i); write(f,x); end; seek(f,filesize(f)-1); truncate(f); close(f); write('Press Enter...'); readln end;
var n,i:integer;
c:char;
x:stud;
begin
write('Удалить запись № ');
readln(n);
reset(f);
if (filesize(f)<n)or(n<0) then
begin
writeln('В файле нет такой записи');
close(f);
write('Press Enter...');
readln;
exit;
end;
if n=filesize(f)then
begin
seek(f,filesize(f)-1);
truncate(f);
close(f);
write('Press Enter...');
readln;
exit;
end;
seek(f,n-1);
for i:=n-1 to filesize(f)-2 do
begin
seek(f,i+1);
read(f,x);
seek(f,i);
write(f,x);
end;
seek(f,filesize(f)-1);
truncate(f);
close(f);
write('Press Enter...');
readln
end;