Hypertrophy Posted July 7, 2009 Share Posted July 7, 2009 how do I append to an ini value that already exists in an inifile. f.e: [Section1] Key=value1 <<< append to this with comma Link to comment Share on other sites More sharing options...
Inverted Posted July 7, 2009 Share Posted July 7, 2009 (edited) Read the value to a string, append another string to that, then write the value Edited July 7, 2009 by Inverted Link to comment Share on other sites More sharing options...
Mat Posted July 7, 2009 Share Posted July 7, 2009 IniWrite ("c:\test.ini", "section1", "key", IniRead ("c:\test.ini", "section1", "key") & ",") that work? MDiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 7, 2009 Author Share Posted July 7, 2009 Thank you mdiesel! That works perfect. Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 7, 2009 Author Share Posted July 7, 2009 (edited) is this the correct way to check if a string exists as a key? $string = "abc" $keycheck = IniReadSection($inifile, "section1") ; reads the section for all key/value pairs If @error Then MsgBox(0, "","Error") Else For $i = 1 To $keycheck[0][0] If $keycheck[$i][0] = $string Then msgbox(0,"","string 'abc' exists as key in ini file") Else msgbox(0,"","string 'abc' not found..") EndIf Next EndIf Edited July 7, 2009 by Hypertrophy Link to comment Share on other sites More sharing options...
Robjong Posted July 7, 2009 Share Posted July 7, 2009 (edited) Hey, try this, so you don't need a loop $sKey = "abc" If IniRead("file.ini", "section", $sKey, "#ITDOESNOTEXIST#") <> "#ITDOESNOTEXIST#" Then ConsoleWrite("Key '" & $sKey & "' exists." & @CRLF) Else ConsoleWrite("Key '" & $sKey & "' does not exist." & @CRLF) EndIf Edited July 7, 2009 by Robjong Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 7, 2009 Author Share Posted July 7, 2009 (edited) Wouldn't a loop be necessary though I there were 10 keys or 20 and you really had no idea of what they might be? Edited July 7, 2009 by Hypertrophy Link to comment Share on other sites More sharing options...
Robjong Posted July 7, 2009 Share Posted July 7, 2009 (edited) Wouldn't a loop be necessary though I there were 10 keys or 20 and you really had no idea of what they might be?If you want to match partial kays or values you would need a loop.Not if you only need an exact match of the key, the last param of IniRead is the default return value for when the key does not exist, so when that value (in this case #ITDOESNOTEXIST#) is returned the key does not exist.Read the help file for IniRead Edited July 7, 2009 by Robjong Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 7, 2009 Author Share Posted July 7, 2009 (edited) Ok. I think im starting to understand. so could i just do like this instead of having "#ITDOESNOTEXIST#" $sKey = "abc" If IniRead("file.ini", "section", $sKey, "") <> "" Then ConsoleWrite("Key '" & $sKey & "' exists." & @CRLF) Else ConsoleWrite("Key '" & $sKey & "' does not exist." & @CRLF) EndIf Would that still work? Edit: Nevermind, added ExitLoop and my code works perfect. Thanks for the help though. Edited July 7, 2009 by Hypertrophy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now