From: TC on
I am familiar with using Get and Seek to read data from binary files and
I've seen examples of using the Put statement to enter material. I was
wondering how one would delete a record / data from a binary file?

Thanks


From: Jeff Johnson on
"TC" <getmyemails2(a)yahoo.com> wrote in message
news:upiC5Rf3IHA.1196(a)TK2MSFTNGP05.phx.gbl...

>I am familiar with using Get and Seek to read data from binary files and
>I've seen examples of using the Put statement to enter material. I was
>wondering how one would delete a record / data from a binary file?

You have to re-write the file without the deleted record. The only other way
would be to copy the following data "up" and then use an API function to
change the length of the file.


From: Larry Serflaten on

"TC" <getmyemails2(a)yahoo.com> wrote
> I am familiar with using Get and Seek to read data from binary files and
> I've seen examples of using the Put statement to enter material. I was
> wondering how one would delete a record / data from a binary file?

Provide a byte in each record as a flag to denote if its active or deleted,
and then just mark the flag.

If that's not the way you want to go, you might read the entire file into
memory, and work on it there to close up the gaps, and then write it
back out as a new file.

LFS


From: dpb on
TC wrote:
> I am familiar with using Get and Seek to read data from binary files and
> I've seen examples of using the Put statement to enter material. I was
> wondering how one would delete a record / data from a binary file?

If the file is opened as Binary, w/ difficulty -- in essence it's the
same thing then as a sequential file, you'll have to keep track of
records, etc., specifically and there's really no way to arbitrarily
delete data any differently than the ways one would go about doing it w/
a sequential file.

If it is opened in Random mode, then one can use the record number for
fixed length records and, as Larry says, use an indicator field in the
record for used/unused records.

To implement this efficiently for large files then needs something like
a linked list or other data structure to keep track of available/free
records or one is reduced to traversing the file looking for the next
free space (or simply ignore it and let the file simply grow if it's not
a permanent file and/or the size won't continue to expand forever).

--
From: TC on
I've got code that loops through a binary file byte-by-byte and creates a
new byte array and then uses that to create a clone via the Put function.

I'm having an issue regarding leaving certain records out. For example, in
Office files that are BIFF format, is it fair to say one would not only have
to understand the BIFF structure and how a record relates to that structure
as well as what the associated application expects?


"dpb" <none(a)non.net> wrote in message news:g4lvgn$anr$1(a)aioe.org...
> TC wrote:
>> I am familiar with using Get and Seek to read data from binary files and
>> I've seen examples of using the Put statement to enter material. I was
>> wondering how one would delete a record / data from a binary file?
>
> If the file is opened as Binary, w/ difficulty -- in essence it's the same
> thing then as a sequential file, you'll have to keep track of records,
> etc., specifically and there's really no way to arbitrarily delete data
> any differently than the ways one would go about doing it w/ a sequential
> file.
>
> If it is opened in Random mode, then one can use the record number for
> fixed length records and, as Larry says, use an indicator field in the
> record for used/unused records.
>
> To implement this efficiently for large files then needs something like a
> linked list or other data structure to keep track of available/free
> records or one is reduced to traversing the file looking for the next free
> space (or simply ignore it and let the file simply grow if it's not a
> permanent file and/or the size won't continue to expand forever).
>
> --