Notifications
Clear all
[Closed] ini files
Jan 20, 2009 3:29 pm
I m back again:rolleyes: lol
i start to work with ini files, and i was wondering how i could automatically add a new key string when i click on an button?
when i click on it, i get a string back and would like to add it into my ini file.
2nd question, how could i get back all of them into an array.
something like
for i = 1 to Ini_key.count do
append StringArray (getINISetting iniExemple Exemple (i as string))
3 Replies
Jan 20, 2009 3:29 pm
Run the code below and read the comments that I have made.
iniPath=(getDir #plugCfg)+"\ estIniFile.ini"
setIniSetting iniPath "theSection1" "theKey1" "theValue1"
setIniSetting iniPath "theSection1" "theKey2" "theValue2"
setIniSetting iniPath "theSection1" "theKey3" "theValue3"
setIniSetting iniPath "theSection2" "theKey1" "theValue1"
setIniSetting iniPath "theSection2" "theKey2" "theValue2"
setIniSetting iniPath "theSection2" "theKey3" "theValue3"
setIniSetting iniPath "theSection3" "theKey1" "theValue1"
setIniSetting iniPath "theSection3" "theKey2" "theValue2"
setIniSetting iniPath "theSection3" "theKey3" "theValue3"
sectionAr=getIniSetting iniPath --Returns an array of all the Sections
keyAr=getIniSetting iniPath sectionAr[1] --Returns array of all the Keys
getIniSetting iniPath sectionAr[1] keyAr[1] --Returns the value for the key
Jan 20, 2009 3:29 pm
and with PEN’s code, doing the button thing is easy as well… in the button press event, you can use just the code for ‘keyAr’, and parse it (for example) as follows:
lastKey = keyAr[keyAr.count]
"theKey3"
lastCounter = (subString lastKey ((trimRight lastKey "0123456789").count + 1) -1) as integer
3
lastCounter += 1
4
setIniSetting iniPath "theSection1" ("theKey" + lastCounter as string) "theValueX"
true