LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Ini File

Hello,
I wrote a function which prototype is as follows :

int myfunc(char *section ,char *filename)

myfunc does the following :
- calls IniNew(1)
- calls IniPutInt(inihdl, section, "tag1", value1)
- calls IniPutInt(inihdl, section, "tag2", value2)
- calls IniPutInt(inihdl, section, "tag3", value3)
- calls IniPutInt(inihdl, section, "tag4", value4)
- calls Ini_WriteToFile (inihdl, filename)
- calls Ini_Dispose (inihdl)

if I call this function let's say 3 times with 3 different "section" names, and same filename, only the last section appears in the inifile.

Here is what I want :
[Section1]
tag1=value1
tag2=value2
tag3=value3
tag4=value4

[Section2]
tag1=value1
tag2=value2
tag3=value3
tag4=value4

[Section3]
tag1=value1
tag2=value2
tag3=value3
tag4=
value4

Here is what I get :

[Section3]
tag1=value1
tag2=value2
tag3=value3
tag4=value4

Looks like each time I call myfunc(), it erases the inifile and rewrites it with only the last section I wrote to the file.
Can anybody help me with this?
I use CVI 6.0 under Windows 2000.

Thanks in advance,
Marco
0 Kudos
Message 1 of 2
(3,186 Views)
Ok, guys,
I found the mistake, I forgot to call Ini_ReadFromFile before putting any
new data in the file, this is, right after Ini_New.
Next time, please remind me to read the old messages before posting!
Sorry for that,

Hasta la vista!
Marco
"Marco" a écrit dans le message de
news:3f71b585@newsgroups....
Hello,
I wrote a function which prototype is as follows :

int myfunc(char *section ,char *filename)

myfunc does the following :
- calls IniNew(1)
- calls IniPutInt(inihdl, section, "tag1", value1)
- calls IniPutInt(inihdl, section, "tag2", value2)
- calls IniPutInt(inihdl, section, "tag3", value3)
- calls IniPutInt(inihdl, section, "tag4", value4)
- calls Ini_WriteToFile (inihdl, filename)
- calls Ini_Dispose (inihdl)

if I call this fun
ction let's say 3 times with 3 different "section" names,
and same filename, only the last section appears in the inifile.

Here is what I want :
[Section1]
tag1=value1
tag2=value2
tag3=value3
tag4=value4

[Section2]
tag1=value1
tag2=value2
tag3=value3
tag4=value4

[Section3]
tag1=value1
tag2=value2
tag3=value3
tag4=value4

Here is what I get :

[Section3]
tag1=value1
tag2=value2
tag3=value3
tag4=value4

Looks like each time I call myfunc(), it erases the inifile and rewrites it
with only the last section I wrote to the file.
Can anybody help me with this?
I use CVI 6.0 under Windows 2000.

Thanks in advance,
Marco
Message 2 of 2
(3,186 Views)