BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

append log at the start of the file

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Tue Jan 30, 2007 9:12 am    Post subject: append log at the start of the file Reply with quote



I want to append the log details(messages) at the start of the file
each time.
we have eof , is any option for start of file.
can anyone pls help me
Back to top
Guest






PostPosted: Wed Jan 31, 2007 3:12 am    Post subject: Re: append log at the start of the file Reply with quote



On Jan 29, 10:58 pm, anandarama...@gmail.com wrote:
Quote:
I want to append the log details(messages) at the start of the file
each time.
we have eof , is any option for start of file.
can anyone pls help me


You're basically making a new file each time for something like this.
You aren't appending information; you're inserting. If you're using a
TFileStream, then any writing will overwrite existing data. One option
is to load the file into a TStringList and Insert() your entries at a
0 position. Aside from that, if you are using lower level routines
then you'll want to look at making a temporary file, writing your
contents, then copying over the contents of the existing log file.
This method is doing essentially the same thing as the TStringList
method; except that it's just using a different method to buffer the
file. The downfall of the TStringList method is that you'd be loading
the entire log file into memory; so you may want to just stick with
the lower level routines so you can copy it by chunks.

The question you may also want to ask, is whether or not you really
need to insert your log entries at the top. Why not just write the log
file normally, but read it in reverse? I imagine you're going to be
writing to the log file a lot more than you would be reading it; so
save the more time consuming methods and routines for the event that
happens the least.

-- Michael
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.