Board index » delphi » How to open a big text file
MOHAMMED AL_HEELA
![]() Delphi Developer |
Tue, 02 Apr 2002 03:00:00 GMT
|
MOHAMMED AL_HEELA
![]() Delphi Developer |
Tue, 02 Apr 2002 03:00:00 GMT
How to open a big text file
How to open a big text file.
|
Bruce Robert
![]() Delphi Developer |
Tue, 02 Apr 2002 03:00:00 GMT
Re:How to open a big text fileThere are numerous ways to work with text files: 1. Use a tStringList and LoadFromFile. Probably not a great idea for QuoteMOHAMMED AL_HEELA <al_heela2...@hotmail.com> wrote in message Quote> How to open a big text file. |
th..
![]() Delphi Developer |
Thu, 04 Apr 2002 03:00:00 GMT
Re:How to open a big text fileIn article <38070794.18232...@hotmail.com>, MOHAMMED AL_HEELA <al_heela2...@hotmail.com> wrote: Quote> How to open a big text file. megs or more, you should avoid reading it into memory if at all possible as it can take a lot of time eg. if you read it into a StringList using load from file, the system will appear to lock up while it read it in - definately NOT the way to go. If you have to read it all into memory, write you own procedure to do so. That way you can at least display some sort of status message and give an option to abort. Perhaps using a stream would be the best way to go because you could then read in part of the file at a time. If the user scrolls to another part, you can load in the next block. Could be a problem if they need to edit it. I hate how most editors eg. NotePad, Visual C++ editor etc. just blindly load in a huge file, say 100M, and don't give you an option to cancel (picked the wrong file!) or at least to see some of the file while it loads the rest. It is also a good way to blow away all your resources (memory that is). I wrote a programmable text editor to allow me to edit unlimited text trevor Sent via Deja.com http://www.deja.com/ |
Sundial Service
![]() Delphi Developer |
Thu, 04 Apr 2002 03:00:00 GMT
Re:How to open a big text fileQuoteth...@my-deja.com wrote: would basically treat the file as a series of "regions," some of which might have been pre-loaded into memory, some of which still resided only in the input file. Of the regions that had been loaded, some had been modified (these I kept in memory, although I could have spilled them out to a scratch-file); the others had not and were therefore discardable or reusable. Later on I started to discover some of the many "container classes" for If you think about it, there is no particular reason why you need to ------------------------------------------------------------------------ Quote> Got Paradox/Delphi database headaches? ChimneySweep{tm} can help, FAST! |
stev
![]() Delphi Developer |
Fri, 05 Apr 2002 03:00:00 GMT
Re:How to open a big text fileI think what you want are win32 memory-mapped files. This allows you to access the file as if it is in memory, and the operating system handles all file region page swapping for you. You can access the file sequentially or randomly, both for reading and writing. This is very handy as you can use the file by just reading and writing a pointer to memory and all file handling is dealt with for you. Try looking at the win32 help on CreateFileMapping. You create a file handle with CreateFile, and then map it using CreateFileMapping. I have seen an article somewhere that created a delphi class to encapsulate the functionality but can't remember where - perhaps you could search for it, unless someone else in the newsgroup knows. QuoteSundial Services wrote: |
Engard Feren
![]() Delphi Developer |
Fri, 05 Apr 2002 03:00:00 GMT
Re:How to open a big text fileQuoteOn Sun, 17 Oct 1999, Sundial Services wrote: do a text-editor working like this? That is, I can make changes, insert and delete things, browse the file and I need not to move 100's of megabytes until I finally say 'save'. Quote>When faced with a similar objective, long ago, I created a class that Thx: __ @ |
stev
![]() Delphi Developer |
Sat, 06 Apr 2002 03:00:00 GMT
Re:How to open a big text fileTry looking at this article: http://www.borland.com/delphi/news/zd/1999/apr99/ QuoteEngard Ferenc wrote: |
2. (Fwd) Re: Saving big arrays of char in text files
3. Saving MS Word files / Bmp files/ text / rich text files in SQL Server
4. how2 TMemo - Automatic scroll bars appear when text too big, disappear when text fits
5. Database File Size keeps getting bigger and bigger
6. Opening header files without opening the same .CPP file
7. Opening very large text files