TIniFile.GetStrings

From Soldat Community Wiki
Jump to: navigation, search
procedure GetStrings(List: TStrings)
 List: list of strings of TIniFile

Description

This procedure reads all lines of TIniFile and save them to TStrings
It reads comment lines as well, in a strange way though ("// comment" --> "=// comment").
It doesn't save empty lines.

Example

Example reads example.ini from server's root folder

var
  l: TStringList;
  ini: TIniFile;
  i: integer;

begin
  l := File.CreateStringList();
  // assuming Sandbox Level < 2
  ini := File.CreateINI('example.ini');
  
  ini.GetStrings(l);
  for i:=0 to l.Count-1 do
    WriteLn('>> '+l[i]);
  
  l.Free;
  ini.Free;
end.