LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

INI temperory file in CVI?

In my system, I use ini file to record UUT's information. After all test finished, I update its ini file. But sometime I found there is a temperory file in UUT's directory(each UUT has a specific directory), the name like ini$$0.TMP or ini$$1.TMP, and the original ini file was not updated. Who can tell me how to prevent this problem, in which way it generate the tmp file.
I can't found any information about this in NI's web and help file. I found Ini_WriteToFile may generate temp file in its help file.
0 Kudos
Message 1 of 5
(3,434 Views)
You're right: Ini_WriteToFile first writes to a temporary file (named "ini$$x.tmp") and then replaces original file with the temporary one deleting it. If you find this temporary file and your original file is not updated it means that some error has prevented the function to complete, but in this case you shoud receive an error by Ini_WriteToFile function. I suggest you test the return code from this function to be informed on wether it succeeded or not. The function (like almost all functions in this instrument) returns error status in an integer which can be translated to a meaningful string with GetGeneralErrorString (erroCode).


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?
Message 2 of 5
(3,428 Views)
Thanks for your reply.

This problem is not easy to be repeated. I want to know how to prevent this or how do I do if I encounter this problem.
Can I just reuse Ini_WriteToFile, like this:

while((status=Ini_WriteToFile())==0) {
    Delay(0.01);
}

0 Kudos
Message 3 of 5
(3,425 Views)

In my opinion trying to patch an unknown error can be dangerous. Let's make an example: you are getting a "permission denied" error while trying to rename temporary file to the original file name; since this is a structural error whose conditions are not subject to change in time, you will be tied in an endless loop of infinte errors without solution!

The basic of all error strategies is to know what is happening before proceeding to correct it; so turning back to my basic question: are you receiving some error code from Ini_WriteToFile ( ) ?



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?
Message 4 of 5
(3,422 Views)
Infact I can not repeat this problem, so I havn't receive any error. I have tried to open this ini file using word, but there is no tmp ini file generated.
0 Kudos
Message 5 of 5
(3,419 Views)