For my use, it seems to work very well.  I am creating a file where it pretty 
much appends a new entry to the end of a file,  but occasionally the process 
needs to over-write the previous entry.  This TStringlist is indeed very easy 
to work with this Tstringlist, especially since I was given an example, Thanks 
Anthony!   For this process I need to write the file out for every entry, but I 
can think of some other places I could use this and just build the entire file 
in the TStringList and just write it all out once I'm done.

Sometimes I need to remember I have GB of ram now, and everything doesn't have 
to fit in a few K of ram anymore 😊 

-----Original Message-----
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Rik van Kekem
Sent: Tuesday, April 03, 2018 8:17 AM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Seek with text file

Op 03-04-2018 13:58 schreef James Richters:
> Thank you for the advice and for the example. I don't know what is considered 
> a large file.. these files can be maybe about 1000 lines long, most will be 
> less, would this solution be suitable for files of this size?
> 
> Is Tstringlist something like an array of strings?

Yes, TStringList is a TList with strings.
Internally it's indeed an array of strings.

 From the code-snippet from Anthony you can see it's really easy to use.

1000 lines of about average 70 characters per lines would be 72*1000=70MB. For 
current computers with memory in the GB this is not large at all. TStringList 
would also be fast to read individual files.

If you however would need to do this for say 2000 files in a row, it could 
become slow and you would need to code it differently to make it more 
efficient. But for just a few individual files this is the easiest method.

Rik
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to