Hi
can someone help me with this conversion please. Or give me advise on doing things differently.
My program reads a text file and the process it. At the moment I use TStringList.LoadFromFile function, to load a text file. Then process it.
This is not good for huge text files.
Now I got an example how to read block by block :
repeat
blockread(srcFile, Buffer^, sizeof(Buffer^), bytesRead);
if BytesRead = sizeof(Buffer^) then
seek(srcFile, filepos(srcFile)-10);
Inc(numReads);
import.Add(pchar(buffer));
until (bytesRead = 0);
Here you can see I load every buffer, size is 64K, to import, which is TSTringList.
Now I get into import for each buffer, 64K of lines, inot each import line. So
import[0]=1st 64K of lines...
import[1]=2nd 64K of lines...
I would like to have
import[0]=1st line from file
import[1]=2nd line form file
...
So I need to convert buffer into each line and get it inot import.
I would like to use
import.AddString(buffer)
but it doesn't work... I try
import.AddString(PChar(buffer)) ... still doesn't work.
(err: Incompatible type ... String and PChar ...)
So I need to convert Pchar into String.
Can anyone help me with this one.
Thanx
can someone help me with this conversion please. Or give me advise on doing things differently.
My program reads a text file and the process it. At the moment I use TStringList.LoadFromFile function, to load a text file. Then process it.
This is not good for huge text files.
Now I got an example how to read block by block :
repeat
blockread(srcFile, Buffer^, sizeof(Buffer^), bytesRead);
if BytesRead = sizeof(Buffer^) then
seek(srcFile, filepos(srcFile)-10);
Inc(numReads);
import.Add(pchar(buffer));
until (bytesRead = 0);
Here you can see I load every buffer, size is 64K, to import, which is TSTringList.
Now I get into import for each buffer, 64K of lines, inot each import line. So
import[0]=1st 64K of lines...
import[1]=2nd 64K of lines...
I would like to have
import[0]=1st line from file
import[1]=2nd line form file
...
So I need to convert buffer into each line and get it inot import.
I would like to use
import.AddString(buffer)
but it doesn't work... I try
import.AddString(PChar(buffer)) ... still doesn't work.
(err: Incompatible type ... String and PChar ...)
So I need to convert Pchar into String.
Can anyone help me with this one.
Thanx