Difference between revisions of "TIniFile.SectionExists"

From Soldat Community Wiki
Jump to: navigation, search
(new page)
 
m (Example)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
  '''''function SectionExists(const Section: string): Boolean'''''
 
  '''''function SectionExists(const Section: string): Boolean'''''
 
   Section: Section name
 
   Section: Section name
   Result: TRUE if a section exists in assigned [[TIniFile]]<br>
+
   Result: TRUE if a section exists<br>
  
 
==Description==
 
==Description==
Line 32: Line 32:
 
   Ini.CaseSensitive := TRUE;
 
   Ini.CaseSensitive := TRUE;
 
   temp := Ini.SectionExists('Exampleupper'); // temp = FALSE
 
   temp := Ini.SectionExists('Exampleupper'); // temp = FALSE
 +
  Ini.Free;
 
end.
 
end.
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:TIniFile]]
 
[[Category:TIniFile]]

Latest revision as of 02:30, 21 August 2013

function SectionExists(const Section: string): Boolean
 Section: Section name
 Result: TRUE if a section exists

Description

This function will check whether a section exists in a TIniFile and return TRUE if so, FALSE otherwise.

Example

example.ini in soldatserver's root folder

[ExampleSection]
exvalue=2

[ExampleUPPER]
exvalue2=3

script code:

const
  // assuming Sandboxed Level < 2
  PATH = 'example.ini';
var
  Ini: TIniFile;
  temp: Boolean;

begin
  Ini := File.CreateINI(PATH);
  temp := Ini.SectionExists('ExampleSection'); // temp = TRUE
  temp := Ini.SectionExists('Exampleupper'); // temp = TRUE
  Ini.CaseSensitive := TRUE;
  temp := Ini.SectionExists('Exampleupper'); // temp = FALSE
  Ini.Free;
end.