ini [v0.15.1]

Author: Tuncay Last Modified: 20100205


Operate on variables instead of files. An easy to use ini parser.

With the custom functions I wrote here, the user accessess on variables instead of files. This is super fast, in comparison to disk access. Ini files can be created by Ahk just like any other variable. But Ahk itself does not have any function to operate on ini strings (variables). If you read often from ini file, then this might for you.

ini_buildPath(_Path)
Ini_Delete(ByRef _Content, _Section, _Key = "")
ini_exportToGlobals(ByRef _Content, _CreateIndexVars = false, _Prefix = "ini", _Seperator = "_", _SectionSpaces = "", _PreserveSpace = False)
ini_getAllKeyNames(ByRef _Content, _Section = "", ByRef _count = "")
ini_getAllSectionNames(ByRef _Content, ByRef _count = "")
ini_getAllValues(ByRef _Content, _Section = "", ByRef _count = "")
ini_getKey(ByRef _Content, _Section, _Key)
ini_getSection(ByRef _Content, _Section)
ini_getValue(ByRef _Content, _Section, _Key, _PreserveSpace = False)
ini_insertKey(ini, "Section", "Key=" . A_Now)
ini_insertSection(ini, "Section", "Key1=ini`nKey2=Tuncay")
ini_insertValue(ini, "Section", "Key" ",ListItem")
ini_load(ByRef _Content, _Path = "", _convertNewLine = false)
ini_mergeKeys(ini1, ini2)
Ini_Read(ByRef _OutputVar, ByRef _Content, _Section, _Key, _Default = "ERROR")
ini_repair(_Content, _PreserveSpace = False, _CommentSymbols = ";#", _LineDelim = "`n")
ini_replaceKey(ini, "Section", "Key")
ini_replaceSection(ini, "Section", "[Section1]Key1=0`nKey2=1")
ini_replaceValue(ini, "Section", "Key", A_Now)
ini_save(ByRef _Content, _Path = "", _convertNewLine = true, _overwrite = true)
Ini_Write(_Value, ByRef _Content, _Section, _Key)

For the functions's parameters and return value, please see it's source code or the document.

Remarks

http://en.wikipedia.org/wiki/UUID

For update's details and remarks related to the functions, please see the AutoHotkey Forum: http://www.autohotkey.com/forum/viewtopic.php?t=14917

For update's details and remarks related to the functions, please see the AutoHotkey Forum: http://www.autohotkey.com/forum/viewtopic.php?t=46226

License

The functions is an open source item under the GNU LGPL license.
For details, please see lgpl-3.0.txt

Example

; #Include ini.ahk
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

; ----- User Configuration -----
ConfigFilePath := "settings.ini"


; ----- Main -----
IfNotExist, %ConfigFilePath%
    createConfigFile(ConfigFilePath)

FileRead, ini, %ConfigFilePath%
value := ini_getValue(ini, "Config", "Started")
value++
ini_replaceValue(ini, "Config", "Started", value)
updateConfigFile(ConfigFilePath, ini)

FileRead, ini, %ConfigFilePath%
value := ini_getValue(ini, "Config", "Started")
MsgBox This script was started %value% time/s.


RETURN ; End of AutoExec-section


createConfigFile(Path)
{
    Template =
    (LTrim
    [Config]
    Started=0
    )
    FileAppend, %Template%, %Path%
    Return
}


updateConfigFile(Path, ByRef Content)
{
    FileDelete, %Path%
    FileAppend, %Content%, %Path%
    Return
}