BowlofPetunias
Programmer
I am a novice, and am using turbo delphi.
I would like to read some data from a binary file. I have found where in the file the information is, and can extract most of it, however there are three numbers that i can not read correctly.
I know what I should be reading from the file.
I have tried reading them as real, single, double with no success.
I have written the numbers to another file as reals and read them succesfully. I have examined the data i wrote to the file and the data from the file I am trying to read with a hex editor and they appear identical.
I have been trying to figure this out for days and am at my wits end trying to figure it out.
I appreciate any help you can give.
I would like to read some data from a binary file. I have found where in the file the information is, and can extract most of it, however there are three numbers that i can not read correctly.
I know what I should be reading from the file.
I have tried reading them as real, single, double with no success.
I have written the numbers to another file as reals and read them succesfully. I have examined the data i wrote to the file and the data from the file I am trying to read with a hex editor and they appear identical.
I have been trying to figure this out for days and am at my wits end trying to figure it out.
I appreciate any help you can give.
Code:
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
Type
ccadtype = record
dummy_1 : array[1..4] of byte;
point_number : array[1..16] of char; { 1234567890123456 }
point_code : array[1..16] of char; { 1234567890123456 }
point_east : array[1..8] of byte; { 123456.789 }
point_north : array[1..8] of byte; { 987654.321 }
point_level : array[1..8] of byte; { 999999.999 }
dummy_2 : array[1..44] of byte;
x_scale : single; { 555.555 }
y_scale : single; { 666.666 }
rotation : single; { 333.5592 }
dummy_3 : array[1..4] of byte;
end;
Var
point : ccadtype;
inf : file;
outf : text;
initial_offset, counter : longint;
num_read, rec_size, fp_ccf, fp_inf, fs_inf : integer;
xx : byte;
begin
initial_offset := $21204; (* 21204h 135684d*)
counter := 0;
rec_size := SizeOf(point);
Assign(inf, 'd:\tp5\cc6\test.cc6');
Reset(inf, 1);
fs_inf := FileSize(inf);
fp_inf := FilePos(inf);
WriteLn('*** File Size is ... ', fs_inf );
WriteLn('*** File Ptr is ... ', fp_inf );
WriteLn('*** size point east ... ', sizeof(point.point_east) );
WriteLn('*** size x scale ... ', sizeof(point.x_scale) );
Writeln('Record Size is ...', Rec_Size);
WriteLn('File Size is ...', Sizeof(inf));
Seek(inf, initial_offset);
Repeat
fp_inf := FilePos(inf);
WriteLn('*** File Ptr is ... ', fp_inf );
Blockread(inf, point, rec_size, num_read);
Inc(counter);
WriteLn(counter:20, ' ', point.point_number);
Until Eof(inf);
close(inf);
end.