Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

Parsing a typed file

hi! i have a file of unknown record type.  is there a way to find out what my file of record is composed of? thanks in advance!
0
dabestprogrammerindauniverse
Asked:
dabestprogrammerindauniverse
1 Solution
 
billiousCommented:
No.

At least, not with any certainty.

All files would be accessible as a file of byte, but that's hardly useful - you probably want to know how to get the records out of the file - whatever the records are.

If the file was created using 'file of type', then all the records are the same length, so the record length must be a factor of the filesize. If you have different versions of the file, you may be able to calculate the length by calculating all of the possible factors of the various different versions, and the ones that are common are the likely record sizes.

Having found the record size, then you've got to determine the structure - quite another ball-game.

It may be a text file, where reading with the text type would work.

There may be a variable-length record structure where a particular byte may mark the end-of-record. This byte may or may not be used exclusively as end-of-record, for instance if you
  write(file,x,y,#4);  write(file,j,k,#4);

  where x and j are integers and y and k are different-length strings, then a hex '04' byte may occur as part of the integer, but will occur at the end-of-record, while the record length is variable(but marked by a hex '04' byte)

So it may or may not be comprehensible other than to the application that created it.

...Bill
0
 
ILECommented:
now with the code


when u wona read any file

var fil: file of byte;
   pos:longint;
    b:byte;  
begin
assignfile(fil,'filename');
reset(file)
seekfile(file,pos);  {pos is position what byte u wona read}
readfile(file,b)     {in b u got the bute u read}
closefile(fil);
end;
this metod with eny seek will be read just one byte an mey use for read any file




when u use a typed file this is a file with known structure


var file file of recstruc; {where recstruc is any type}
b:rectrruc;
  pos:longint;

begin
assignfile(fil,'filename');
reset(file)
seekfile(file,pos);  {pos is position what record u wona read}
readfile(file,b)     {in b u got the record u wona read}
closefile(fil);
end;





0
 
dabestprogrammerindauniverseAuthor Commented:
any other ideas? thanks :)
0
 
CleanupPingCommented:
dabestprogrammerindauniverse:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now