Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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.

Posted

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!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...