From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Content of Ini-File with config-data sometimes deleted?

Hello,
i have a simple vi attached where i read config-data from a file.
Sometimes it happens that the content is lost. I am not sure why, but perhaps there a errors in the vi.
I wonder about the last vi "Close Config Data" there is an onput-parameter "write configuration file? (T)".
Why is this parameter set to default-TRUE? Could it be that i shouzld set it to False? Perhaps this
close-vi overwrite my data with nothing.

The vi reads the section [Par1] from this file:

[Par1]
PathFile=C:\\profile.txt
[Par2]
PathFile=C:\\variants.txt

and returns --> C:\\profile.txt

Thx for your help
0 Kudos
Message 1 of 9
(4,310 Views)
If you intend the file to be read-only it is best to set the write parameter of the close function to FALSE.

Out of curiosity. You mention that sometimes the data in the ini file is lost. What kind of machine are you using? Do you close the application neatly? Do you always close the file neatly?
Regards,
André (CLA, CLED)
Message 2 of 9
(4,287 Views)
It is a Windows XP SP2-System with Labview 8.21 and TS 3.5.
Its running a custom executable Labview Operator-Interface which runs teststand-sequences.
I thought the file is closed correct with the code that i attached, or do i have to add soomething else that it is really closed?
The apllication is sometimes shutdown with taskmanager so its not closed neatly. But i think this is no problem for this text-file because its is only read once and the closed.
I will change the parameter to False and see what happens.
Thx for your help

0 Kudos
Message 3 of 9
(4,279 Views)
If the parameter is set to true and you quit the application through the task manager at the wrong point in time. During write the file could be corrupted.
Regards,
André (CLA, CLED)
0 Kudos
Message 4 of 9
(4,258 Views)

The values set by using the INI file functions only exist in memory and are NOT written to disk until the "Close" VI with the constant set TRUE.

If your code executes in multiple threads where one thread sets the values but another thread closes the file without the constant set true, the values will be removed from memory and will not be written to disk.

So make sure you only execute the "Close" after all values have been set and make sure the constant is set true when the files are closed.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 9
(4,248 Views)
I only open the Ini-file to read the values. I never write something or change something in the file.
The file is only executed once at the beginning of my application. So when i close the application with taskmanaher the execution is finished long ago.
0 Kudos
Message 6 of 9
(4,244 Views)

I think it is time for us to stop guessing and take a look at your code.

I have used INI files for years and they work fine so there must be something in the way you are using them that we just can't see without your code.

Still trying to help,

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 9
(4,242 Views)
Hello Ben,
the code is attached in my first posting in this thread.

There is only one thread which reads the ini-file (never write to it).


>The values set by using the INI file functions only exist in memory and are NOT written to disk until the "Close" VI with the constant set TRUE.

So if there is a problem somewhere in the LAbview-memory and the content is removed there, then "nothing" is saved when executing the Close-VI with True?


Thx for your help.
0 Kudos
Message 8 of 9
(4,172 Views)

Hi,

 

I have the same issue with my project (LabVIEW and Teststand) the content of my ini file is lost "sometimes"

Have you found a solution for your project?

 

 

0 Kudos
Message 9 of 9
(3,331 Views)