 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
DavideP Guest
|
Posted: Mon Apr 02, 2007 7:55 pm Post subject: FileRead and FileSeek |
|
|
Hi, everybody.
I've a tricky question.
How can read fastly and cleverly the *last* line of a file, using
FileRead and FileSeek functions?
Alternatively, there is a fast and smart method?
Thanks in advance.
Davide |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Apr 02, 2007 9:37 pm Post subject: Re: FileRead and FileSeek |
|
|
"DavideP" <no.spam (AT) here (DOT) plz> wrote in message
news:4611197e$1 (AT) newsgroups (DOT) borland.com...
| Quote: | How can read fastly and cleverly the *last* line of a file,
using FileRead and FileSeek functions?
|
Unless the file has fixed-length lines that are all the same length,
then there is no direct way to determine where the last line is
located. You would have to scan through the file forwards from start
to end until you find the last linebreak, or scan backwards until you
find the first line break.
Gambit |
|
| Back to top |
|
 |
Ed Mulroy Guest
|
Posted: Mon Apr 02, 2007 11:23 pm Post subject: Re: FileRead and FileSeek |
|
|
At times in the past I have had to do that. I used a technique similar to
what Remy Lebeau told you. I seeked to the end of the file -2048, read a
2048 byte buffer, searched back from the end to find the end of the line
character (the ending '.', '?' '!') or the last alpha-numeric (some people
omit the punctuation on the last line of a paragraph). I then seeked back
to find the end of line character before that. The start of the last line
is then the first non-blank character going forward from that second end of
line.
.. Ed
| Quote: | DavideP wrote in message
news:4611197e$1 (AT) newsgroups (DOT) borland.com...
Hi, everybody.
I've a tricky question.
How can read fastly and cleverly the *last* line of a file, using FileRead
and FileSeek functions?
Alternatively, there is a fast and smart method? |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|