Issam
Issam

Reputation: 186

Delete specific record from file of records

I have the next data structure :

 Type
 TMyRecord=Record
                 Num:String[50];
                 ID:String[50];
   
 End;

and I have a file of record Like the next :

Var
F:File of TMyRecord;

the file will contains many records , how I can delete one specific record from the file.

Thank you in advance .

Upvotes: 0

Views: 337

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 595827

If the record is at the very end of the file, you can simply truncate the size of the file to omit the record.

Otherwise, the only way to delete a record from the beginning/middle of the file is to create a new file, copy the existing records from the old file to the new file omitting the record you want to delete, and then replace the old file with the new file.

Upvotes: 3

Related Questions