Is there any way to delete a record in a typed file? For example:
In the above code delete (var f:whatype ; i:longint) would remove the ith record of file f and reduce the file size by one. Does such a function exist?
Hopefully such a function would delete any record but all I really need is to delete the last record.
If I have to write the function myself the only strategy that comes to mind is to copy the entire file, sans ith record, to a second file, then delete the first file and rename the second file. Is there a more elegant strategy?
Thanks in advance for any assistance. I am traveling and will probably not be able to check any responses before 16Jul06.
Code:
type
whatype = file of string ;
var
f : whatype ;
i : longint ;
begin
i := 99 ;
assign (f, 'whatever') ;
reset (f) ;
delete (f,i) ;
close (f)
end.
In the above code delete (var f:whatype ; i:longint) would remove the ith record of file f and reduce the file size by one. Does such a function exist?
Hopefully such a function would delete any record but all I really need is to delete the last record.
If I have to write the function myself the only strategy that comes to mind is to copy the entire file, sans ith record, to a second file, then delete the first file and rename the second file. Is there a more elegant strategy?
Thanks in advance for any assistance. I am traveling and will probably not be able to check any responses before 16Jul06.