Jump to content

.ini ReWrite


Recommended Posts

I have built an .ini with a certain amount of variables under a certain Section. The order of the keys in the section is essential to the program...is there any way i can change the value of the keys without having to delete the key and adding a new one which will go to the end of the section??

Link to comment
Share on other sites

i don't understand your problem well

but you can use IniWrite

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

well if you used it with an existing key with existing value & existing section

it will just replace it

example :

you have this ini

[Section]
1=1
2=2
3=3

use this code

IniWrite("New Text document.txt","Section","2","Changed")

and it will change the calue of key 2 to Changed with the same order

Edited by komalo
[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

ARozanski

Try this:

$sResult = _IniWriteEx(@ScriptDir & "\test.ini", "Section", "NewValue", "NewKey", 2)

Func _IniWriteEx($sPath, $sSection, $sVal, $sKey, $sPos)
    Local $aSection, $iRead, $i
    $aSection = IniReadSection($sPath, $sSection)
    
    For $i = 1 To $aSection[0][0]
        If $i = $sPos Then $iRead &= $sVal & "=" & $sKey & @LF
        $iRead &= $aSection[$i][0] & "=" & $aSection[$i][1] & @LF
    Next
    
    Return IniWriteSection($sPath, $sSection, $iRead)
EndFunc

:P

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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