An application from Delphi 1 (16 bit) has been transfered into Delphi 2007.
The Delphi 1 program has created files with the following type definition:

type
  codePost = record
    code        : integer;        {code 3 figures}
    value       : longint;        {value 6 figures}
    data        : string;         {Data max 30 chrs}
    date        : string;         {}
    FFnow       : boolean;        {FF is in progress}
  end;

var
  post : codePost;
  f    : file of codePost;

To make the Delphi 2007 version run I had to change my type definition. When new program tries to read the old files it has no success.
In Delphi 2007 the type definition is:

type
  codePost = record
    code        : smallint;       {code 3 figures}
    value       : longint;        {value 6 figures}
    data        : string[30];     {Data max 30 chrs}
    date        : string[10];     {}
    FFnow       : boolean;        {FF is in progress}
  end;

var
  post : codePost;
  f    : file of codePost;

I have tried to change the type declaration in different ways, but the best I managed was to get code shown correctly, value too many digits and data shown without first character (type: code:smallint; value:integer). Then the rest are wrong, as of course all subsequent records.

Does anybody have a knowledge about how I can change my type definitions to make this fit?

Firstly you shouldnt have had to change the size of your record, if your record was defined in delphi 1 without sizes, you should have been ok with "string" now.. the record alightment is most likely the parts thats wrong.

When I first had "string" I got an compile error "'codepost' needs finalization - not allowed in file type".
That is why I changed to string[30], as data is read from a database with field size 30 chrs.

Im still concerned that the record size is different. Are you able to measure the length of the records from the file in delphi 1? to check you have the same size?

Yes you are probably right. But also my variable "value" (longint) obviously reads 5 bytes in 2007 whereas Delphi 1 has written only 4 bytes. I have read one char at a time but haven't found any solution yet.

You could read them all in bytes, and then overlay them into the various fields, Although, Im surprised its 5 bytes in 2007... Id expet it always to be 1 or an even number..

Solution was "packed" in my type declaration, smallint and shortstring.

Thanks

This question has already been answered. Start a new discussion instead.