[Lazarus] What is the revision number of release 0.9.26.2?
Graeme Geldenhuys
graemeg.lists at gmail.com
Sun Apr 5 09:24:01 CEST 2009
Hello:
I am astonished. It breaks my heart, I am crying: Nobody has even
mentioned the old-fashion classic Pascal way for reading a text file.
Traitors. ;-)
Loading a text file in a TStringList with LoadFromFile method is a good
option, it is easy, it is simple and you can access to any line whenever
you want. But, Why to load the whole file in memory if you only need to
process the lines sequentially from the beginning to the end
(particularly if it is a big file)?
Procedure ReadThisFile(FileName:string);
var
f:TextFile;
OneLine:string;
begin
assignFile(f,FileName);
reset(f);
while not eof(f) do begin
readln(f,OneLine);
// do whatever you want with OneLine, for example write it on the output
writeln(OneLine);
closefile(f);
end;
PD: well, at least Borland Pascal way. I think standard Pascal uses
"text", "assign" and "close" instead of TextFile", "AssignFile" and
"Closefile"
Santiago A.
More information about the Lazarus
mailing list