hi
i seem to have run into a problem when adding records to a Typed file that already exists.
I have used ReWrite method to create the file in the first place.
// Open the file for writing To
AssignFile(F, ExtractFilePath(Application.ExeName) + 'bin\drivers\' +
(frm_vars.Driver1.Caption) + '\card.digi');
Rewrite(F);
// Move To The End Of The File
Seek(F, FileSize(F));
// Write a couple of records to the file
Limits.tenhourdrive := ShortString(frm_vars.L10HrDriveAvailable1.Caption);
Limits.fifteenhourshift :=
ShortString(frm_vars.L15HrShiftAvailable1.Caption);
Write(F, Limits);
// Close the file
CloseFile(F);
however if i check if the file exists, and then add records using Reset(F); it duplicates the first records in the file and then adds new ones on the end.
Can somebody who knows more than me please explain why this might be happening.
Here is the code im using to add records to an existing file
if SysUtils.FileExists(LimitsFile) then
begin
AssignFile(F, ExtractFilePath(Application.ExeName) + 'bin\drivers\' +
(frm_vars.Driver1.Caption) + '\card.digi');
Reset(F);
// Move To The End Of The File
Seek(F, FileSize(F));
// Write a couple of records to the file
Limits.tenhourdrive := ShortString(frm_vars.L10HrDriveAvailable1.Caption);
Limits.fifteenhourshift :=
ShortString(frm_vars.L15HrShiftAvailable1.Caption);
Write(F, Limits);
// Close the file
CloseFile(F);
ShowMessage('File Updated!');
Reset(F);
end;
thanks