Re: Update file

new topic     » goto parent     » topic index » view thread      » older message » newer message

Ad Rienks wrote:

>from your example I deduce that in update mode a line can be replaced, =
> but
> only if the new line is exactly the same length as the old one. Is this t=
> he
> only way to work in update mode? Is it for instance not possible to inser=
> t
> a line in between other lines?
> I know it is possible to append lines at the end of a file, but for that
> purpose you also have the append mode.
> Personally when I update a file, I first read them into (a) sequence(s),
> close the file and after updating I open the file again for writing. Mayb=
> e
> this is more time-consuming, but when time is not that important, at the
> beginning and end of a program.....
>
You "could" insert a longer line ( more bytes } into a disk file, but
you'd have to move all the following bytes to make room. That would be
time-consuming. This has nothing to do with Euphoria, any programming language
requires this, except for a full data base engine, which solves the problem of
inserts and deletes by creating links and indexes to pieces of data. New pieces
are stored at the end of the physical file, and retrieved via list pointers.

All this moving and linking is automatic when using sequences.
Trouble is, that it can take a looong time to read/write a big sequence
from disk. Too long, when the data file begins to reach a usable length.
A lot of the extra time is used up in reading/writing two, three or four
bytes for each data byte (ascii character, for example.)
.
Irv

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu