en:code:data:inifile
This is an old revision of the document!
Table of Contents
IniFile
This object allows you to read and write to a INI file.
Functions
IniFile
Constructor function.
Syntax
var myObject = new IniFile();
var myObject = new IniFile(parameters);
Arguments
- parameters - (object) parameters
- delimiter - (char) the delimiter to use
- commentchar - (char) the comment character
- encoding - (Encoding) the encoding to use
Exceptions
- (ParameterTypeError) incorrect parameter type
- (ParameterCountError) incorrect parameter count
Example
Create a IniFile object.
var myObject = new IniFile();
Create a IniFile object with parameters.
var myObject = new IniFile({ delimiter: "=", commentCharacter: "$", });
Methods
load
Loads a file.
Syntax
myObject.load(filename);
Arguments
- filename - (string) the filename of the file to open
Returns
- (IniFile) this IniFile
Exceptions
- (LoadFileError) cannot load the file
save
Saves a file.
Syntax
myObject.save(filename);
Arguments
- filename - (string) the filename of the file to save
Returns
- (IniFile) this IniFile
Exceptions
- (SaveFileError) cannot save the file
clear
Clear the file.
Syntax
myObject.clear();
Returns
- (IniFile) this IniFile
preserveDeletedData
Preserve the deleted data as comments.
Syntax
myObject.preserveDeletedData(preserve);
Arguments
- preserve - (boolean) should the deleted data preserved as comments
Returns
- (IniFile) this IniFile
setDelimiter
Set the value/data delimiter. Default is =.
Syntax
myObject.setDelimiter(delimiter);
Arguments
- delimiter - (char) the delimiter to use
Returns
- (IniFile) this IniFile
setCommentCharacter
Set the comment character. Default is #.
Syntax
myObject.setCommentCharacter(commentchar);
Arguments
- commentchar - (char) the comment character
Returns
- (IniFile) this IniFile
setSection
Sets the current INI section.
Syntax
myObject.setSection(sectionName);
myObject.setSection(sectionName, create);
Arguments
- sectionName - (string) the section name
- create - (boolean) create the section if it doesn't exists (default: true)
Returns
- (IniFile) this IniFile
Exceptions
- (FindSectionError) cannot find the section
setEncoding
Sets the encoding to use.
Syntax
myObject.setEncoding(encoding);
Arguments
- encoding - (Encoding) the encoding to use
Returns
- (IniFile) this IniFile
sectionAt
Returns the section name at index sectionIndex.
Syntax
myObject.sectionAt(sectionIndex);
Arguments
- sectionIndex - (integer) the section index
Returns
- (string) the section name
Exceptions
- (FindSectionError) cannot find the section
deleteSection
Deletes a section.
Syntax
myObject.deleteSection(sectionName);
Arguments
- sectionName - (string) the section name
Returns
- (IniFile) this IniFile
Exceptions
- (FindSectionError) cannot find the section
sectionCount
Returns the number of sections.
Syntax
myObject.sectionCount();
Returns
- (integer) the section count
keyExists
Returns true if a key with keyName exists.
Syntax
myObject.keyExists(keyName);
Arguments
- keyName - (string) the key name
Returns
- (boolean) true if a key with keyName exists
keyAt
Returns the name of the key at index keyIndex.
Syntax
myObject.keyAt(keyIndex);
Arguments
- keyIndex - (integer) the key index
Returns
- (string) the key name
Exceptions
- (FindSectionError) cannot find the section
keyValue
Returns the value of the key keyName.
Syntax
myObject.keyValue(keyName);
Arguments
- keyName - (string) the key name
Returns
- (string) the key value
setKeyValue
Sets the value of the key keyName.
Syntax
myObject.keyValue(keyName, value);
Arguments
- keyName - (string) the key name
- value - (string) the key value
Returns
- (IniFile) this IniFile
deleteKey
Delete the key keyName.
Syntax
myObject.deleteKey(keyName);
Arguments
- keyName - (string) the key name
Returns
- (IniFile) this IniFile
Exceptions
- (FindSectionError) cannot find the section
keyCount
Returns the key count.
Syntax
myObject.keyCount();
Returns
- (integer) the key count
en/code/data/inifile.1295984975.txt.gz · Last modified: 2021/02/13 11:23 (external edit)