Difference between revisions of "WriteINI"
From SCAR Divi Manual
(→Example) |
(→Description) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
==Description== | ==Description== | ||
− | Writes data to a file with an [http://en.wikipedia.org/wiki/INI_file INI] structure. The function creates a new file specified by the path '''FileName''' when it does not yet exist, else it opens the existing file at that path and changes it without destroying the current contents of the file. The function writes a value specified by '''NewString''' at the key specified by '''KeyName''' in the section specified by '''Section'''. The function returns [[true]] if it was successful in writing the value. If '''Section''' or '''KeyName''' are empty, the function will return [[false]]. | + | Writes data to a file with an [http://en.wikipedia.org/wiki/INI_file INI] structure. The function creates a new file specified by the path '''FileName''' when it does not yet exist, else it opens the existing file at that path and changes it without destroying the current contents of the file. The function writes a value specified by '''NewString''' at the key specified by '''KeyName''' in the section specified by '''Section'''. The function returns [[true]] if it was successful in writing the value. If '''Section''' or '''KeyName''' are empty, the function will return [[false]]. When '''FileName''' contains an invalid file path, an exception is thrown and the script is stopped. |
===File structure=== | ===File structure=== | ||
Line 32: | Line 32: | ||
*[[ReadINI]] | *[[ReadINI]] | ||
*[[DeleteINI]] | *[[DeleteINI]] | ||
− | |||
*[[INISectionExists]] | *[[INISectionExists]] | ||
*[[INIKeyExists]] | *[[INIKeyExists]] |
Latest revision as of 12:01, 1 July 2011
Definition
function WriteINI(Section, KeyName, NewString, FileName: string): Boolean;
Availability
SCAR Divi 3.00 > Current
- Before SCAR Divi 3.21 WriteINI did not have a return value.
Description
Writes data to a file with an INI structure. The function creates a new file specified by the path FileName when it does not yet exist, else it opens the existing file at that path and changes it without destroying the current contents of the file. The function writes a value specified by NewString at the key specified by KeyName in the section specified by Section. The function returns true if it was successful in writing the value. If Section or KeyName are empty, the function will return false. When FileName contains an invalid file path, an exception is thrown and the script is stopped.
File structure
[Section] Key=Value
Example
begin WriteINI('Section', 'Key', 'Hello World!', LogsPath + 'Test.ini'); WriteLn(ReadINI('Section', 'Key', LogsPath + 'Test.ini')); DeleteFile(LogsPath + 'Test.ini'); end.
Output:
Hello World!