LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Ini_PutDouble does not work for 1000.0

The following code does not put the correct value into an ini file.

Ini_PutDouble(iniText, "SHUNT", "Nominal G2 High", 1000.0);

It writes:
[SHUNT]
Nominal G2 High = 0:00

It should write:
[SHUNT]
Nominal G2 High = 1000.0

Other values do work.
I have tried
9999.9999
10000.0
999.0

Any ideas?
0 Kudos
Message 1 of 8
(3,451 Views)
What version of CVI and Windows are you using? I can't duplicate your results using CVI 6.0 and Windows 2000.
How are you viewing the results? If you're using your own software to read the INI file, try opening it in Notepad to double check the results.
I used the sample project ...\CVI\samples\toolbox\ini.prj that ships with CVI and inserted the following line in NewItem() after the Ini_PutString() line.
Ini_PutDouble(g_myInifile, "SHUNT", "Nominal G2 High", 1000.0);

I also tried casting 1000.0 as double.
Ini_PutDouble(g_myInifile, "SHUNT", "Nominal G2 High", (double) 1000.0);

Both methods worked the same. The output lines in the INI file were:
[SHUNT]
Nominal G2 High = 1000
0 Kudos
Message 2 of 8
(3,445 Views)
I am using
CVI 5.5.1
CVI RTE 7.1.1.314
Windows 2000 SP4

I am using notepad to view the result.
If I start with the correct values in the ini it works.
If I try to generate the ini with CVI it does not.
0 Kudos
Message 3 of 8
(3,444 Views)
Did you try explicitly casting it as a double as in my second example?

Ini_PutDouble(iniText, "SHUNT", "Nominal G2 High", (double) 1000.0);
0 Kudos
Message 4 of 8
(3,438 Views)
Using:
Ini_PutDouble(iniText, "SHUNT", "Nominal G2 High", (double) 1000.0);

Results in:
[SHUNT]
Nominal G2 High = 0:00

I have found a work around:
Fmt (Buffer, "%f", 1000.0);
Ini_PutString (iniText, "SHUNT", "Nominal G2 High", Buffer);
0 Kudos
Message 5 of 8
(3,425 Views)

I'm using CVI2010 and had to use:

 Ini_WriteToFile (g_myInifile, g_fileName); 

in order to write to file after the change.

 

 

0 Kudos
Message 6 of 8
(2,830 Views)

That's the expected behaviour.

The IniText is a structure in memory. You load it from a file on disk with Ini_ReadFromFile and save it with Ini_WriteToFile. Nothing strange with it.

 

Additionally, if you want to modify only some items in an existing .INI file while preserving the others, you must read the file, meodify desired values with the appropriate Ini_Put function and save it again, otherwise only the modified values will be savet to disk and other elements will be lost.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 8
(2,817 Views)

@nesaboz79

I just focused on the original posts, which date back to 2005! It is better to open a new thread instead of reviving such a very old one.

In case the new question is related to the old thread you can link it as a reference.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 8 of 8
(2,811 Views)