LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with configuration file losing data

I am using labview 5.1 on a win98 machine, and am having troubles with
my configuration file losing data.

I am using the Configuration File VIs to store the current values of a
number of controls for both the front panel and several sub-vis in one
configuration file, which then I read in when I start my program.

Every time I access my config file, I open, read or write to it, then
close it. After writing a key to my config file, I close it with the
save option so that it saves my info to the config file. Viewing my
config file with an external viewer shows that the data is being saved.

At no time do I delete a section or key, but they seem to be
disappearing. At times, I look in my config file and see very little
inform
ation. Of the 30 or so controls that I am tracking, only about 10
may actually be there. This is most noticeable when I start my program
and several important controls read 0. When I start labview, do I need
to read in all the sections and keys before saving? Or should the
configuration vis only add (or change) the data that is written to a
key?

Thanks,
Scot
0 Kudos
Message 1 of 3
(2,561 Views)
You should be able to read and write single key values without a problem. Is there a small subset of your application that displays this effect that you could either post or send me?

Mike...
mporter@arielcorp.com

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 3
(2,561 Views)
You have a race condition problem. As the config file is read from many places in the application, one copy is made each time and they are updated independently. Thus the last piece of code to save the config file overwrites previous changes that occurred and were saved elsewhere. This is similar to reading, modifying, writing a global string from many places in the application: writing overwrites previous changes that occurred since it was copied.

To prevent this situation, open the config file only once in the application and make the refnum available to all VIs using it. To write a key, use the refnum to write it. Config VIs uses only one copy of that data so you are sure that all keys written and not overwritten. Close the config file only when you a
re done with it at the end of the application. If you need to save the config file after each operation, use the VI "vi.lib\utility\config.llb\Config Data Write to File.vi". This VI saves the config data on file without closing the refnum so the copy remains in memory.


LabVIEW, C'est LabVIEW

0 Kudos
Message 3 of 3
(2,561 Views)