Sample program: |
The following short program shows how to read a text file line by line. The read lines are displayed in the console window:
program ReadTextFile;
var
i : integer;
FName : string;
fs : TIlabFStream;
astr : string;
begin
FName := SelectFile (GetILabDir(idWork), '*.txt', 'Select a file');
if FName <> '' then
begin
fs := TIlabFStream.Create (FName, fmOpenRead);
while not fs.Eos do
begin
astr := fs.ReadLn(0);
couts (astr);
end;
fs.Free;
end;
end.
|