Re: Re[6]: [fpc-pascal] read lines at end of file

2011-05-29 Thread John Lee
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 who

Re[6]: [fpc-pascal] read lines at end of file

2011-04-14 Thread José Mejuto
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 famili

Re[4]: [fpc-pascal] read lines at end of file

2011-04-12 Thread José Mejuto
Hello FPC-Pascal, Tuesday, April 12, 2011, 12:51:17 AM, you wrote: jgc> So the idea is to open file eg as file of array [1:65536] of char or jgc> something similar, seek & read to end of file, then go through the last jgc> array converting to strings by finding crlfs correct? Is this the simplest

Re[2]: [fpc-pascal] read lines at end of file

2011-04-12 Thread José Mejuto
Hello FPC-Pascal, Tuesday, April 12, 2011, 1:09:34 AM, you wrote: RW> On 04/11/2011 12:32 PM, John Lee wrote: >> Need to read the last 4 lines (txt) of a very large log file 100M >> bytes, 100k lines or more lots of times - of course I can read RW> Hmm, could first have the reader enumerate th

Re: [fpc-pascal] read lines at end of file

2011-04-11 Thread Robert Wolfe
On 04/11/2011 12:32 PM, John Lee wrote: Need to read the last 4 lines (txt) of a very large log file 100M bytes, 100k lines or more lots of times - of course I can read through the file in the normal way but this is rather slow. Is there a way to 'read lines from the end'? I note that unix tai

Re: Re[2]: [fpc-pascal] read lines at end of file

2011-04-11 Thread johnelee1944
So the idea is to open file eg as file of array [1:65536] of char or something similar, seek & read to end of file, then go through the last array converting to strings by finding crlfs correct? Is this the simplest way? If not any outline code? John On , José Mejuto wrote: Hello FPC-Pas

Re[2]: [fpc-pascal] read lines at end of file

2011-04-11 Thread José Mejuto
Hello FPC-Pascal, Monday, April 11, 2011, 7:55:01 PM, you wrote: >> The idea is easy, instead reading forward, you read backwards in >> blocks of, say, 64 Kb and count lines back. If not enougth lines you >> insert another 64 Kb before and so on. Average line is usually less >> than 100 bytes, so

Re: [fpc-pascal] read lines at end of file

2011-04-11 Thread Mattias Gaertner
On Mon, 11 Apr 2011 19:45:10 +0200 José Mejuto wrote: > Hello FPC-Pascal, > > Monday, April 11, 2011, 6:32:20 PM, you wrote: > > JL> Need to read the last 4 lines (txt) of a very large log file 100M bytes, > JL> 100k lines or more lots of times - of course I can read through the file > in > J

Re: [fpc-pascal] read lines at end of file

2011-04-11 Thread José Mejuto
Hello FPC-Pascal, Monday, April 11, 2011, 6:32:20 PM, you wrote: JL> Need to read the last 4 lines (txt) of a very large log file 100M bytes, JL> 100k lines or more lots of times - of course I can read through the file in JL> the normal way but this is rather slow. Is there a way to 'read lines

[fpc-pascal] read lines at end of file

2011-04-11 Thread John Lee
Need to read the last 4 lines (txt) of a very large log file 100M bytes, 100k lines or more lots of times - of course I can read through the file in the normal way but this is rather slow. Is there a way to 'read lines from the end'? I note that unix tail or its port to windows does this very fast