Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repositioning cursor in a text file

Status
Not open for further replies.

JasonDBurke

Programmer
Jun 20, 2001
54
US
I'm a currently reading a log using the Delphi I/O functions that work with the TextFile variable. Because the log is dynamic in nature, on a one second timer iteration I check the file size and see if it has changed. If it is larger then I need to reset the cursor to begin reading again starting where the previous EOF was. How do I accomplish this with a TextFile?? It seems that TextFile does not like Seek or FileSeek and Reset is used for structure sizes. All I want to do is reposition where I previously left off.

Thanks,
Jason
 
Do you have to use the Delphi I/O functions?

It would be easy using a TStringList. Although there may be some problems if the log got very large in which case a TFileStream would be better.

So presumably you have a couple of routines? One routine is the one second timer event handler which puts lines into a queue and the other is the function that provides the next line from the queue to the main part of the application.

These two should be wrapped up in a class to make things tidy and to hide the implementation details.

Andrew

 
You can't do what you want with a text file. The functions that you need are Seek, GetSize and GetPos and these are available with TFileStream and also the Delphi file functions that work with a handle.

Roger Fedyk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top