Difference between revisions of "TIniFile.ReadBool"

From Soldat Community Wiki
Jump to: navigation, search
(new page)
 
(No difference)

Latest revision as of 00:46, 21 August 2013

function ReadBool(const Section, Ident: string; Default: Boolean): Boolean
 Section: Section name
 Ident: Property name (key)
 Default: Value used as a result when the key has not been found
 Result: Value of a key (if successful) or Default (if not)

Description

This function will try to read a boolean (TRUE/FALSE) value from specified section and key
If it fails to do so for some reason, the Default value is returned.
Note that TRUE and FALSE values are saved in the ini file as 1 (TRUE) and 0 (FALSE).

Example

example.ini in soldatserver's root folder

[ModConfig]
AutoStart=1

script code:

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

begin
  Ini := File.CreateINI(PATH);
  temp := Ini.ReadBool('modconfig','AutoStart',FALSE); // temp = TRUE
  Ini.Free;
end.