TIniFile.SectionExists

From Soldat Community Wiki
Revision as of 01:21, 21 August 2013 by Mighty (talk | contribs) (new page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
function SectionExists(const Section: string): Boolean
 Section: Section name
 Result: TRUE if a section exists in assigned TIniFile

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
end.