Sample program: |
The following short program shows how to use a string list. It creates a new string list, loads a text file into the list, sorts the individual lines and outputs the sorted lines on the console.
program SortTextFile;
var
i : integer;
FName : string;
sl : TStringList;
begin
sl := TStringList.Create;
FName := SelectFile (GetILabDir(idWork), '*.txt', 'Select a file');
if FName <> '' then
begin
sl.LoadFromFile (FName);
sl.Sort;
couts('sorted text lines:');
for i:=1 to sl.Count do
couts(sl[i-1]);
end;
sl.Free;
end.
|