Re: Reading binary files of irregular format with TMemoryStream



Thanks for the input guys. I appreciate it.

One thing that troubles me is the field data itself. For example, what
if I am told that a field is 4 bytes in length and somehow it gets
chopped to 2? If I go in with a for/next loop and read 4 bytes, then
I've read in the 2 byte field ID as well thinking its part of the data.
I know there's nothing I can do about that, it'll just be bad data. But
I have to process 700-1000 files at a time. I just need to make sure my
process doesn't crash.

I think checking for the position/size in the While/Do is just what I
was looking for.

I'm getting a copy of a corrupted file sent to me so I can inspect it a
bit more. All of the data in these files is binary. It works like this:

100 0 6 82 79 66 69 82 84
101 0 6 75 73 76 82 79 89
255 255

The above would tell me that field ID 100 is 6 characters long. I get
the ORD values of each byte after to get the letters. So that would
translate to:
100 =ROBERT
101=KILROY

I'm not sure how the files can get corrupted, but they have. So I guess
my main concern is just to know when I get to the end of the file and
let the chips fall where they may.

I think a problem I have is if I do a for/next loop to read 6 bytes and
I reach the end of the file prematurely can I recover?

But you have given me a direction to go in and I appreciate the help!

Robert Kilroy

.



Relevant Pages

  • Re: Can inner join replace multiple loop selects?
    ... The only wrinkle is not incrementing between R and L ... So somehow I need to read the entire group, set a boolean bHaveL and then ... Loop through each of those and set bHaveL variable for each ...
    (comp.databases.ms-access)
  • Re: Explanation about for
    ... I must somehow visualize it in order to understand ... Database cursor is the pointer that iterates over the result set one ... I though that it was the name we give to the whole mysql result set ... You can break each x apart within the loop: ...
    (comp.lang.python)
  • User Defined Class : How to expose a collection of properties?
    ... Could I use the FOR EACH construct to loop through the properties ... (grin). ... Prev by Date: ...
    (microsoft.public.scripting.vbscript)
  • RE: Use DataGrid To Add New Records
    ... I somehow have to loop through the dataset to get the columns ... and then build the columns in the datagrid based on those columns. ... snippet would be helpful. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: object passing problem
    ... I am getting to the bottom of the troubles with my app but am a bit stuck ... HANDLE hThread=CreateThread (NULL, 0, SendCardDataThread, ... the loop and finally 6357069 for the third and final time. ...
    (microsoft.public.pocketpc.developer)