TStringList

Declaration: TStringList = class(TStrings)
The class TStringList maintains a collection of strings. It can be used to store and manipulate the collection of strings. The collection can be seen as a 0-based array of strings. The following list provides the most important properties and methods of the TStringList class:

Properties

Methods

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.