Link to home
Start Free TrialLog in
Avatar of veraps
veraps

asked on

Formatted file

Hi.. I'm trying to read a binary file. The structure of the file is:

0    ~   1     1     ~     2
|TRF HRU Z|   |Id Res RecLen NF Res  FN Res  Flag  ID FD T  IT Res S Res AF Res|

TRF – Total Records on File
HRU – Highest Record available on the directory  
Z – Zeroes that take up space or it may have copyright info

Id – The number of the file   Ex: F1.Dat F1.Dop
Res – Just a space
RecLen – Record size
NF – Number of fields
FN – File Name
Flag – Data state
ID- Initial Date     Stored  in this format     (yymmdd )
FD- Final Date     Stored  in this format     (yymmdd )  
T-Time
IT-Intraday Time
S-Symbol
AF- Auto Run Flag


NB:  
The Format is an old binary format that requires to be converted to a IEEE standard float.

The code was written in Delphi.


the conversion to IEEE standard float is (in delphi):
Function Ms_to_Ie(Var ms) : Real;
  Var
    ie : Array [1..6] of Byte Absolute r;
    m    : My_real Absolute ms;
    r    : Real;
   
begin
  FillChar(r, sizeof(r), 0);
  ie[1] := m[4];
  ie[4] := m[1];
  ie[5] := m[2];
  ie[6] := m[3];
  Ms_to_ie := r;
end;  

The problem is...
can I read the file not with a delphi program? I mean, I make the program with other language? and how do I do that? I mean should I read the file byte per byte and translate it to ieee float? I really don't understand what to do with the file! thanks..
Avatar of Carel
Carel

You can read the file with any language that can read files in binary mode, so Delphi is be able to load it. You could define a structure or record that mimics the structure of your file, then load it and use the structure for accessing the elements.
ASKER CERTIFIED SOLUTION
Avatar of john_gabriel
john_gabriel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of veraps

ASKER

Answer accepted