I have an error code 1 when I try to write to a text file in my application. I really don't understand and don't know how to fix this problem.
If anyone can please help me fix this problem, it would be greatly appreciated!
Solved! Go to Solution.
Where is the error actually occurring?
I find it very odd how many times you branch some wires outside of structures then pass them into the structure through multiple tunnels.
It is also odd that in the default 0 case, you write to the file, close it, then read from it. (but not open it again, but that may occurr automatically), then close it again. Why?
sorry about the tunnels.
the first vi that I use to write is because I am trying to make an xml in a txt file and these are the first lines and in the second case I want to enter information in between these lines and also srite it to the same text file.
The error occurs in the second write to text file vi.
Don't close the file in case 0. Only close it after your while loop is done. Keep your file refnum stored in a shift register.
My guess is that you open the file outside the while loop and you pass in the refnum and use it within case 0. Then you close the file which kills the refnum. You then open the file again (possibly automatically with the Read) then close that. When you get to case 1, you use the same refnum that you originally opened up outside, but that has been closed and is now invalid.
This is a prime example of how to NOT use local variables! Its not that local variables are "Evil" but, that is a really poor use! Once written in parallel to the main loop (Absolutely no data dependancy to the main loop so it can be written FALSE once at any time!) Once Written TRUE in the main loop (But only if both Paths are not empty strings and a float cast to int is exactly 1) and Once read as a loop termination condition. AND- get this, the USER can't even see the control since it is hidden!
Yes, you need to re-think that vi a bit.
Averna Automated Test Systems
Why are you still closing the file and then reading it in case 0? You are going to get back exactly what you just put in. Get rid of the close and the File Read.