Board index » delphi » There must be some way to append to untyped files!

There must be some way to append to untyped files!

On 17 Nov 1995, Trixter / Hornet wrote:

Quote
> I've just finished my own library routines, and I discovered the
> hard way that Append() only appends to a text file.  Argh!  To
> write my AddFileToLib() function, I've had to do this:

> This works for small files, but is rediculous when creating libraries
> over 5 or 6 megabytes--takes n log n time no matter how small the
> file is you're adding!

> Hence, my question:  Is there any way to simply add or append to
> a binary (untyped) file?  Using some convolution of seek(f,filesize(f))
> is all I can think of, but of course that only works with reading...

That's not true. I looked up the help on SEEK, and it says, that
seek(f,filesize(f)) is defined for f opened for writing in order to append
existing files, exactly what you want! If f is opened for reading, then
this command would lead to an IO-error.

Adios, ALEX

------------------------------------------------------------------
        __    _     _
      _(  |__\ \   / /    Alexander Schweimler
     /  ) | __\ \ / /     Gerbertstr. 1
    / * | ||__ \ \ / *    D-79117 Freiburg
   /  * | | __| > / ***   Tel.   : +49-761-66542
  /   _ | ||__ / ^ \ *    e-mail : schwe...@ruf.uni-freiburg.de
 /___/ || |___/ / \ \
-------|  |__/_/---\_\---*--------+++++++-------------------------
    ** (______\ ***

 

Re:There must be some way to append to untyped files!


In article <Pine.SOL.3.91.951118004027.28466A-100...@sun2.ruf.uni-freiburg.de>,
Alexander Schweimler  <schwe...@sun2.ruf.uni-freiburg.de> wrote:

Quote
>> Hence, my question:  Is there any way to simply add or append to
>> a binary (untyped) file?  Using some convolution of seek(f,filesize(f))
>> is all I can think of, but of course that only works with reading...

>That's not true. I looked up the help on SEEK, and it says, that
>seek(f,filesize(f)) is defined for f opened for writing in order to append
>existing files, exactly what you want! If f is opened for reading, then
>this command would lead to an IO-error.

Excellent!  I can't believe I made this assumption.  Thanks for the
info!
--
Jim Leonard (Trixter / Hornet)                          Email: trix...@mcs.com
Check out *THE* PC Demo WWW page:  http://www.mcs.net/~trixter/html/demos.html
The 8086 Compo is a reality! URL is http://www.cdrom.com/pub/demos/hornet/8086
Make A Computer easy enough for a fool to use, and only fools will use it!

Re:There must be some way to append to untyped files!


In article <48iu58$...@Mercury.mcs.com>,
   trix...@MCS.COM (Trixter / Hornet) wrote:

Quote
>I've just finished my own library routines, and I discovered the
>hard way that Append() only appends to a text file.  Argh!  To
>write my AddFileToLib() function, I've had to do this:
> .
> .
>Hence, my question:  Is there any way to simply add or append to
>a binary (untyped) file?  Using some convolution of seek(f,filesize(f))
>is all I can think of, but of course that only works with reading...
>Can anyone help me?

Why does it only work for reading? I've used it very successfully for years to
append to the end of a binary file.

Assign(f, 'name');
Reset(f, 1);
Seek(f, Filesize(f));
BlockWrite(f, stuff, sizeofstuff);

If your file attributes are set to read only then you will have to change that
before you can write.

-----------------------------------------------
Mike Chapin
Powder River
-----------------------------------------------

Re:There must be some way to append to untyped files!


Quote
On Sun, 19 Nov 1995, Joe Jared wrote:
> trix...@MCS.COM (Trixter / Hornet) wrote:

> >>That's not true. I looked up the help on SEEK, and it says, that
> >>seek(f,filesize(f)) is defined for f opened for writing in order to append
> >>existing files, exactly what you want! If f is opened for reading, then
> >>this command would lead to an IO-error.

> >Excellent!  I can't believe I made this assumption.  Thanks for the
> >info!

> One important detail you need to be fully aware of:

> With untyped files, you need to define a record size, which will
> "ususlly" be 1.  By default however, it is NOT 1.

> Reset(filevar) if the record size is undefinedI believe is the same
> as: reset(filevar,128);

Borland's decision of making the deafult record size of 128 has caused me
no small amount of pain, suffering and "what the {*word*30}? this should work!" :)

    ________________________________________________________________________
   / Joshua Shagam                    /    (Quantum Porcupine / Versatile) /
  / mailto:JSha...@nmsu.edu          /       http://web.nmsu.edu/~jshagam /
 / phone://1.505.645.3856/~joshua   /  for the Quantum Porcupine Archive /
/__________________________________/____________________________________/
 Stop the execution of King Louis XIV!  If you agr-- oops, too late! :)

Re:There must be some way to append to untyped files!


Quote
Quantum Porcupine <jsha...@nmsu.edu> wrote:

|>
|Borland's decision of making the deafult record size of 128 has caused me
|no small amount of pain, suffering and "what the {*word*30}? this should work!" :)

It made perfect sense when it first appeared under CPM for reading
128-byte sectors from an 8 inch floppy

Phil

     The earth is populated by scientists who practice the art of
     infallibility, and non-scientists who are taken in by them.

               (with credit to whomever I copied it from)

Other Threads