TIniFile.ReadFloat

From Soldat Community Wiki
Jump to: navigation, search
function ReadFloat(const Section, Ident: string; Default: Double): Double
 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 Double (decimal) value from specified section and key
If it fails to do so for some reason, the Default value is returned.

Example

example.ini in soldatserver's root folder

[ModConfig]
DamageModifier=1.73

script code:

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

begin
  Ini := File.CreateINI(PATH);
  temp := Ini.ReadFloat('ModConfig','DamageModifier',1); // temp = 1.73
  Ini.Free;
end.