open and read commands
Fairlight
fairlite at fairlite.com
Sun Dec 2 10:52:21 PST 2007
Is it just me, or did fp at casabellagallery.com say:
> Personally, I find that using import is simpler than open(), readline(),
> and seek() for sequentially manipulating a file.
Generally speaking, unless you need to do some really fancy footwork, you
wouldn't be using seek with readline. In fact, depending upon the nature
of how they implemented seek, well...some incarnations of seek aren't
friendly to buffered I/O.
And honestly, import is -far- less flexible than raw I/O. It may be easier
for the fP old-timers, but I find the exact opposite to be true of you,
coming at it from the standpoint of having worked with many other
languages--import is a bit arcane, simplifies things, but utterly lacks
flexibility that raw I/O affords you.
As with the HTML commands, I think it makes sense to just learn how to
do it right the first time around. The difference is that I acknowledge
import has a useful side to it compared to the HTML crud.
> That said, to answer your question: - You MUST look into the usage of
> openline(), readline() and seek() to get the job done. Readline() alone
> will not do what you are thinking of, at least not the way you are
> approaching it (just speculating judging from your posts). You need to
> use seek() to place your pointer, readline() to extract content.
You only need seek if you're wandering around the file. If you're using
readline, it reads each line in sequential order. I have no idea why
you're suggesting the two be mixed, but again...buffered I/O is notoriously
unfriendly to seek, depending on what you're doing to the file.
mark->
More information about the Filepro-list
mailing list