This object allows you to read and write to a INI file.
Usable example:
var myObject= new IniFile(); myObject.load("config.ini"); myObject.setSection("SomeSettingsSection"); if (myObject.keyExists("SomeKey")){ mytext = myObject.keyValue("SomeKey"); newtext = mytext + "Bar"; myObject.setKeyValue("SomeKey", newtext); }else{ myObject.setKeyValue("SomeKey", "Foo" ); mytext = cfgini.keyValue("SomeKey"); } myObject.save("config.ini");
Will result in value "Bar" being appended ever run, except first. Defaults to "Foo" if Key is unset:
Constructor function.
var myObject = new IniFile();
var myObject = new IniFile(parameters);
Create a IniFile object.
var myObject = new IniFile();
Create a IniFile object with parameters.
var myObject = new IniFile({ delimiter: "=", commentCharacter: "$" });
Loads a file.
myObject.load(filename);
Saves a file.
myObject.save(filename);
Clear the file.
myObject.clear();
Preserve the deleted data as comments.
myObject.preserveDeletedData(preserve);
Set the value/data delimiter. Default is =.
myObject.setDelimiter(delimiter);
Set the comment character. Default is #.
myObject.setCommentCharacter(commentchar);
Sets the current INI section.
myObject.setSection(sectionName);
myObject.setSection(sectionName, create);
Sets the encoding to use.
myObject.setEncoding(encoding);
Returns the section name at index sectionIndex.
myObject.sectionAt(sectionIndex);
Deletes a section.
myObject.deleteSection(sectionName);
Returns the number of sections.
myObject.sectionCount();
Returns true if a key with keyName exists.
myObject.keyExists(keyName);
Returns the name of the key at index keyIndex.
myObject.keyAt(keyIndex);
Returns the value of the key keyName.
myObject.keyValue(keyName);
Sets the value of the key keyName.
myObject.setKeyValue(keyName, value);
Delete the key keyName.
myObject.deleteKey(keyName);
Returns the key count.
myObject.keyCount();