Difference between revisions of "TIniFile.ReadSection"

From Soldat Community Wiki
Jump to: navigation, search
m (Example)
m (Example)
Line 7: Line 7:
  
 
==Example==
 
==Example==
Below example will read whole NETWORK section on startup
+
Below example will read whole NETWORK section of soldat.ini on startup
 
<syntaxhighlight lang="pascal">
 
<syntaxhighlight lang="pascal">
 
var
 
var

Revision as of 20:07, 22 August 2013

procedure ReadSection(const Section: string; Strings: TStrings)
 Section: Section to be read
 Strings: Lines read

Description

This procedure reads whole section of TIniFile and saves it as TStrings

Example

Below example will read whole NETWORK section of soldat.ini on startup

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

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