Difference between revisions of "TIniFile.ValueExists"

From Soldat Community Wiki
Jump to: navigation, search
(new page)
 
m (Example)
 
Line 7: Line 7:
  
 
==Example==
 
==Example==
''example.ini'' in soldatserver's root folder;
+
''example.ini'' in soldatserver's root folder:
 
<syntaxhighlight lang="ini">
 
<syntaxhighlight lang="ini">
 
[Section1]
 
[Section1]
Line 13: Line 13:
 
Key2=
 
Key2=
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
actual script code:
 
<syntaxhighlight lang="pascal">
 
<syntaxhighlight lang="pascal">
 
var
 
var

Latest revision as of 01:43, 23 August 2013

function ValueExists(const Section, Ident: String): Boolean
 Section: Section name
 Ident: Property name (key)

Description

This procedure returns TRUE if a key exists and FALSE otherwise

Example

example.ini in soldatserver's root folder:

[Section1]
Key1=1
Key2=

actual script code:

var
  ini: TIniFile;
  temp: Boolean;

begin
  // assuming Sandbox Level < 2
  ini := File.CreateINI('example.ini');
	
  temp := ini.ValueExists('Section1','Key1'); // temp = TRUE
  temp := ini.ValueExists('Section1','Key2'); // temp = TRUE
  temp := ini.ValueExists('Section1','Key3'); // temp = FALSE
	
  ini.Free;
end.