[fpc-pascal] read lines at end of file

John Lee johnelee0 at gmail.com
Sun May 29 13:32:22 CEST 2011

Hi Jose, all.
I've now (at last!) started using your last4 lines program. Thanks a lot- it
works really well and even on a 100M log file it is really really fast -
faster than 1 msec, which I didn't believe until I timed it using
gettickcount. Also it doesn't generate much disk i/o. Reading the whole log
file would take longer and generate disk i/o - I'm guessing that it doesn't
read the file ... so not sure how it works...?

I've had to make few changes eg increasing the buffer size, because the
lines in my log file are of varying length ans some are rather long eg >
1000 bytes.

Two issues I've encountered, I'm getting an exception abort (efopenerror) if
no file exists and also I get an exception abort if looking for the last 4
lines and it overflows the buffer. Can you pls suggest some code to stop
these, and eg return a 0 length string if either happens?

Thanks again for this help.


On 14 April 2011 16:03, José Mejuto <joshyfun at gmail.com> wrote:

> Hello John,
> Thursday, April 14, 2011, 3:26:48 PM, you wrote:
> JL> Hi there, thanks for this - looks a very complete function. I hadn't
> JL> realised that best way would be to use streaming! I'm trying to write a
> 3
> JL> line test program that just gets last 4 lines of a file.
> JL> I'm not very familiar with obj pascal or streaming.  What vars &  uses
> JL> clauses do I need to call your function?
> JL> this is what I have - I still gets some error messages, missing
> tfilestream,
> JL> tfilelist.
> Just only "Classes". You can do the same using regular pascal files
> but to me TStream is more clear.
> --
> Best regards,
>  José
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110529/cbcd7d07/attachment.html>

More information about the fpc-pascal mailing list