Smotsholle
17-07-2006, 09:13 AM
I'm working on a game project which makes use of binary files to store data. As I continue developing I want to add data to my records (and therefore the binary files), a logical consequence is that the program doesn't support the new type.
So if I try to load an obsolete binary data file the new record structure won't accept it, delphi shows me an error.
The fact that the old file doesn't work isn't a problem to me, but I want to make custom error handling. Of course I tried try-except but this doesn't seem to work.
Example code:
function LoadFromBinFile(filename:string):TMyRecord;
var myFile : File of TMyRecord;
begin
try
AssignFile(myFile, filename);
Reset(myFile);
Read(myFile, result);
CloseFile(MyFile);
except
ShowMessage(filename + ' has an obsolete file structure');
end;
end;
And eventhough I use a try...except the Read-file still gives me the delphi error. I must admit I don't know much about try...except in delphi, but there must be a way to catch this.
Does anyone know a solution to my problem?
So if I try to load an obsolete binary data file the new record structure won't accept it, delphi shows me an error.
The fact that the old file doesn't work isn't a problem to me, but I want to make custom error handling. Of course I tried try-except but this doesn't seem to work.
Example code:
function LoadFromBinFile(filename:string):TMyRecord;
var myFile : File of TMyRecord;
begin
try
AssignFile(myFile, filename);
Reset(myFile);
Read(myFile, result);
CloseFile(MyFile);
except
ShowMessage(filename + ' has an obsolete file structure');
end;
end;
And eventhough I use a try...except the Read-file still gives me the delphi error. I must admit I don't know much about try...except in delphi, but there must be a way to catch this.
Does anyone know a solution to my problem?