Difference between revisions of "TIniFile.SetStrings"

From Soldat Community Wiki
Jump to: navigation, search
(new page)
 
m (Example)
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
  
 
==Description==
 
==Description==
This procedure builds [[TIniFIle]] from ''List''.<br>
+
This procedure builds [[TIniFile]] from ''List''.<br>
It doesn't add to existing lines, it completely rebuilds [[TIniFIle]].<br>
+
It doesn't add to existing lines, it completely rebuilds [[TIniFile]].<br>
 
Doesn't update the file though.
 
Doesn't update the file though.
  
 
==Example==
 
==Example==
 +
<syntaxhighlight lang="pascal">
 
var
 
var
 
   l: TStringList;
 
   l: TStringList;

Latest revision as of 03:30, 23 August 2013

procedure SetStrings(List: TStrings)
 List: Strings that are supposed to be converted

Description

This procedure builds TIniFile from List.
It doesn't add to existing lines, it completely rebuilds TIniFile.
Doesn't update the file though.

Example

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

begin
  l := File.CreateStringList();
  // assuming Sandbox Level < 2
  l.Append('[Section10]');
  l.Append('Key1=3');
  
  ini := File.CreateINI('example.ini');
  
  ini.SetStrings(l);
  WriteLn(ini.ReadString('Section10','Key1','ERROR')); // 3 will be displayed
  
  l.Free;
  ini.Free;
end.