Create a file with one record using the old version and one with the new
and take a look with an editor that shows hex.  Or worst case write a
small app that reads in the two files as binary bytes and display it as
hex in two window panes one above each other.

The differences should jump out at you.  Then you can play with the
Records field alignment etc. to see what happens.

John Dammeyer

Automation Artisans Inc.
http://www.autoartisans.com/ELS/
Ph. 1 250 544 4950


> -----Original Message-----
> From: delphi-boun...@elists.org 
> [mailto:delphi-boun...@elists.org] On Behalf Of wvido...@metsec.com
> Sent: Monday, August 23, 2010 12:41 AM
> To: delphi@elists.org
> Subject: RE: Error reading Binary files using Delphi2006
> 
> 
> 
> Yes, the record is not defined as PACKED but in the compiler 
> option for
> D5  the Align Record Fields option is checked. In D2006 there 
> in now the
> Records Field Alignment with drop down options 0-8, Is this the key
> difference?
> 
> voestalpine - One step ahead
> -----Original Message-----
> From: delphi-boun...@elists.org [mailto:delphi-boun...@elists.org] On
> Behalf Of Richard Saunders
> Sent: 21 August 2010 13:58
> To: delphi@elists.org
> Subject: Re: Error reading Binary files using Delphi2006
> 
>   On 8/20/2010 11:32 AM, wvido...@metsec.com wrote:
> > I wrote an application using delphi5 which reads and writes  binary
> file
> > using TFilestream.  But then when I ported the application to Delphi
> > 2006 the files written using old application returns junk 
> data in the
> > new version.
> 
> The record that is being streamed to/from the file must have 
> a different
> 
> structure between the Delphi versions. While the source code 
> definition 
> of the record can be identical, internal differences between 
> the Delphi 
> versions can cause the internal structure to be different. 
> I'll bet the 
> definition does not specify a PACKED RECORD. If it did the internal 
> structure would likely be identical since PACKED indicates 
> you want the 
> field alignment to be as compact as possible and that result probably 
> did not change between Delphi versions.
> 
> How to fix it? Well, you probably will need to detect files 
> written by 
> the D5 program vs. the D2006 program. If the record is the only thing 
> written to the file then the byte length of the files should 
> differ. You
> 
> could use the byte length to tell you which version of the 
> program wrote
> 
> the file.
> 
> If you look at the file using a hex editor you should be able 
> to detect 
> where the record structures differ. You can then adjust the record 
> definition of the current program to be able to read the older files.
> 
> Finally, I would change the definition to be PACKED RECORD 
> from now on. 
> That would avoid this problem going forward.
> 
> -- 
> Rich S.
> 
> _______________________________________________
> Delphi mailing list
> Delphi@elists.org
> http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
> 
> This email is intended for the addressee only.
> 
> Please see our email policy at 
> http://www.metsec.com/asp/home/edisclaimer.asp
> _______________________________________________
> Delphi mailing list
> Delphi@elists.org
> http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
> 
> 

_______________________________________________
Delphi mailing list
Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to