Sign in to follow this  
Followers 0
AustrianOak

Key getting overwritten?

2 posts in this topic

#1 ·  Posted (edited)

Would this code below overwrite any key and values that were previously in the same section?

INIWrite("C:\Program Files\Location\bud.ini", "Bud", $name, IniRead("C:\Program Files\Location\bud.ini", "Bud", $name, "") & $text & ";")

If so, how may I re-code it to make it append to the section, not overwrite all the date thats already in there...

Edited by nowagain

Share this post


Link to post
Share on other sites



Would this code below overwrite any key and values that were previously in the same section?

INIWrite("C:\Program Files\Location\bud.ini", "Bud", $name, IniRead("C:\Program Files\Location\bud.ini", "Bud", $name, "") & $text & ";")

If so, how may I re-code it to make it append to the section, not overwrite all the date thats already in there...

If the key already exists, IniWrite() will overwrite it.

To create duplicate keys, use IniReadSection() to get the whole section in an array, add elements to the array, then IniWriteSection():

The INI file (before):

[Section One]
One=1
Two=2
Three=3

The script:

; Test_1.au3
Global $sINI = "C:\Temp\Test_1.ini"
Global $avINI = IniReadSection($sINI, "Section One")
ReDim $avINI[UBound($avINI) + 1][2]
$avINI[0][0] = UBound($avINI) - 1
$avINI[$avINI[0][0]][0] = "Two"
$avINI[$avINI[0][0]][1] = "2"
IniWriteSection($sINI, "Section One", $avINI, 1)

The INI file (after):

[Section One]
One=1
Two=2
Three=3
Two=2

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
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
Sign in to follow this  
Followers 0