Selenitic Posted February 25, 2008 Share Posted February 25, 2008 I am trying to remove part of a value of a multi-valued ini key. I tried IniDelete, but that deletes the entire key including any values. My current situation is that I have an ini value like: [section] Key=1, 2, 3 I want to edit it to look like this: [section] Key=2, 3 Thank you for the help. Link to comment Share on other sites More sharing options...
BigDod Posted February 25, 2008 Share Posted February 25, 2008 IniWriteSection("test.ini", "Section", "2,3") Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Selenitic Posted February 26, 2008 Author Share Posted February 26, 2008 Sorry, I should of clarified. I don't know what values 2,3 are. This modification is for notes.ini for Lotus Notes. We are removing one addin to lotus notes, but we do not want delete the whole line because it disables all the addins. Different users use different addins with Lotus Notes, so I can't delete the whole line and write a generic one in its place. Link to comment Share on other sites More sharing options...
Thetan Posted February 26, 2008 Share Posted February 26, 2008 I am interested in how to do this also, let me know if you figure it out. Link to comment Share on other sites More sharing options...
Amundo Posted February 29, 2008 Share Posted February 29, 2008 See if this (AutoIt3 code) will do the trick: CODE;~ $keyname = "DisabledPorts" ;~ $remove = "com5" $keyname = "TCPIP_TcpConnectTimeout" $remove = "0" ;~ $keyname = "EmptyTrash" ;~ $remove = "0" $inifile = "c:\lotus\notes\notes.ini" $sectionname = "Notes" $s = IniRead($inifile, $sectionname, $keyname, "") If StringLen($s) = 0 Then ConsoleWrite("Key not found?" & @CRLF) Exit EndIf ConsoleWrite("$s= " & $s & @CRLF) $rc = StringInStr($s, $remove) ConsoleWrite("$rc= " & $rc & @CRLF) $out = "" If $rc > 0 Then $ss = StringSplit($s, ",") If $ss[0] > 0 Then ; $out = $ss[1] For $i = 1 To $ss[0] $sss = $ss[$i] ConsoleWrite("$ss[" & $i & "]=" & $sss & @CRLF) If StringCompare($remove, $sss) Then ConsoleWrite("Keep " & $sss & @CRLF) If StringLen($out) > 0 Then $out = $out & "," ConsoleWrite("$out = " & $out & @CRLF) EndIf $out = $out & $sss Else ConsoleWrite("Drop " & $sss & @CRLF) EndIf Next ConsoleWrite("String to write is: " & $out & @CRLF) Else ConsoleWrite("No multi-values found?" & @CRLF) EndIf Else ConsoleWrite("String to remove not found?" & @CRLF) EndIf As you can see at the top of the code, I tried several keyvalues, it seems to handle multi, double and single values. Good Luck P.S. All my nice formatting got stripped, but I have no idea what I'm doing anyway, so I'm not surprised! Link to comment Share on other sites More sharing options...
Selenitic Posted February 29, 2008 Author Share Posted February 29, 2008 Thank you that worked perfectly. 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