01-18-2012 01:25 PM
I'm looking for a way to stop error messages during the excecution of a program. The situation is basically this:
I am currently working on a Labview program that interacts with a program on a different computer using text files. Essentially the labview program provides instructions (in the form of a text file with the instructions for what the temperature of a piece of hardware should be), the other program uses these instructions to change the temperature of the hardware. The other program also constantly updates a text file that represents the current temperature of the piece of hardware. My labview program is then grabbing that text file reading it and recording it in an array with many other temperatures.
The problem is that when the labview program is trying to read the file at the same time as the other program is saving it my labview program gets an error message. Because this program is being used in a research study I obviously dont want error messages going off and delaying my program at random invalidating data etc etc. I'm wondering if theres a way to set my program so rather than producing an error message it simply no longer writes a temperature value to that file but writes "X" or "ERROR" in the spot of that value instead.
Is this possible? Am I going about this the wrong way? I'm relatively new to this so any help would be appreciated.
01-19-2012 01:14 PM - edited 01-19-2012 01:14 PM
Nproach,
You need to use the general error handler.vi. If you enter the error code in the [error code] input it will ignore that error. You can then output to your text file with the message output. Also, make sure you use clear errors.vi so it can continue after that.
Hope this helps
Pete
01-19-2012 02:06 PM
Another solution that I use is to copy the file from the network location using the system32.dll Move function. This takes care of any conflicts. There is also a Copy function in the Files Function palette you can try that may work.
Another solution would be to handle error 5 when it occurs, clear it, and repeat the read until it opens it successfully.
01-19-2012 02:13 PM
pretty easy to do- just use a case structure arround your write to file
01-19-2012 02:23 PM - edited 01-19-2012 02:26 PM
Here is what I do for your specific problem
The creator of the file does this:
The consumer of the file does this:
As others have pointed out you might take advantage of the OS file copy functions as they do something similar at a lower level or just retry.