View Full Version : ini files
holycause 01 January 2009, 03: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))
|
|
PEN
01 January 2009, 04:14 PM
Run the code below and read the comments that I have made.
iniPath=(getDir #plugCfg)+"\\testIniFile.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
ZeBoxx2
01 January 2009, 05:57 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
holycause
01 January 2009, 06:28 PM
:buttrock:
thanks a lot guys :D
CGTalk Moderation
01 January 2009, 06:28 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.