Difference between revisions of "INISectionExists"

From SCAR Divi Manual
Jump to: navigation, search
(Created page with "==Definition== <source lang="scar" lines="false"> function INISectionExists(const Section, FileName: string): Boolean; </source> ==Availability== SCAR Divi 3.25 > Current ==Des...")
 
Line 1: Line 1:
 
==Definition==
 
==Definition==
 
<source lang="scar" lines="false">
 
<source lang="scar" lines="false">
function INISectionExists(const Section, FileName: string): Boolean;
+
function INIKeyExists(const Section, KeyName, FileName: string): Boolean;
 
</source>
 
</source>
  
Line 8: Line 8:
  
 
==Description==
 
==Description==
Returns [[true]] if a section specified by '''Section''' in an [http://en.wikipedia.org/wiki/INI_file INI] file specified by '''FileName''' exists. If the file does not exist, the function returns [[false]] as well. When '''FileName''' contains an invalid file path, an exception is thrown and the script is stopped.
+
Returns [[true]] if a key specified by '''KeyName''' in a section specified by '''Section''' in an [http://en.wikipedia.org/wiki/INI_file INI] file specified by '''FileName''' exists. If the file does not exist, the function returns [[false]] as well. When '''FileName''' contains an invalid file path, an exception is thrown and the script is stopped.
  
 
==Example==
 
==Example==
 
<source lang="scar">
 
<source lang="scar">
 
begin
 
begin
   WriteLn(INISectionExists('Section', LogsPath + 'Test.ini'));
+
   WriteLn(INIKeyExists('Section', 'Key', LogsPath + 'Test.ini'));
 
   WriteINI('Section', 'Key', 'Hello World!', LogsPath + 'Test.ini');
 
   WriteINI('Section', 'Key', 'Hello World!', LogsPath + 'Test.ini');
   WriteLn(INISectionExists('Section', LogsPath + 'Test.ini'));
+
   WriteLn(INIKeyExists('Section', 'Key', LogsPath + 'Test.ini'));
  
 
   DeleteFile(LogsPath + 'Test.ini');
 
   DeleteFile(LogsPath + 'Test.ini');
Line 26: Line 26:
  
 
==See Also==
 
==See Also==
*[[INIKeyExists]]
+
*[[INISectionExists]]
*[[GetINISections]]
 
 
*[[ReadINI]]
 
*[[ReadINI]]
 
*[[DeleteINI]]
 
*[[DeleteINI]]

Revision as of 13:29, 1 July 2011

Definition

function INIKeyExists(const Section, KeyName, FileName: string): Boolean;

Availability

SCAR Divi 3.25 > Current

Description

Returns true if a key specified by KeyName in a section specified by Section in an INI file specified by FileName exists. If the file does not exist, the function returns false as well. When FileName contains an invalid file path, an exception is thrown and the script is stopped.

Example

begin
  WriteLn(INIKeyExists('Section', 'Key', LogsPath + 'Test.ini'));
  WriteINI('Section', 'Key', 'Hello World!', LogsPath + 'Test.ini');
  WriteLn(INIKeyExists('Section', 'Key', LogsPath + 'Test.ini'));

  DeleteFile(LogsPath + 'Test.ini');
end.

Output:

0
1

See Also