TIniFile.Clear

From Soldat Community Wiki
Jump to: navigation, search
procedure Clear();

Description

This procedure deletes all entries in a TIniFile, including empty and commented lines.

Example

example.ini in soldatserver's root folder:

[Section1]
Key1=1
Key2=

actual script code:

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

begin
  l := File.CreateStringList();
  // assuming Sandbox Level < 2
  ini := File.CreateINI('example.ini');
  ini.Clear;
  
  ini.GetStrings(l);
  for i:=0 to l.Count-1 do
    WriteLn('>> '+l[i]); // nothing will be displayed since it's all gone
  
  l.Free;
  ini.Free;
end.