04-13-2012 12:22 PM
Hi
The error occurred at the Set Position File. I have no idea what that is.
Please have a look at the attachment, but the VI won't work without some external devices.
Thanks a lot for the help.
04-13-2012 12:31 PM
Put a probe on the error cluster coming out of your file open. My guess is that you have an invalid path, like the error says.
04-13-2012 12:40 PM
Thanks. The file path is fine. The file can actually be written. If I move the file open into the while loop, no error occur. But in that case, the file would be written repeatedly and that's not what I want.
04-13-2012 01:41 PM
Ah, I see.
You're closing your file and invalidating your refnum when you exit the S1 case. Are you intending to do this?
If you intend to stay in the while loop and do another set File Pos, you'll either have to reopen the file or avoid closing it until after the while loop finishes.
04-14-2012 05:20 AM
Taki:
I dont quite understand what refnum means. I think the while loop would keep running. The file would be open before the while loop starts, then the data would be written into the file. I wonder if this should be right: when the writing is done, the file should be closed. It won't be open until new data is coming in.
Thanks!
04-14-2012 04:14 PM
If you only want to open the file for each read operation, you need to place the open part inside the loop. If you open it outside the loop, you should only close it outside the loop.
It is typically much more efficient to keep the file open for the duration of the program. Why do you want to close it?
04-15-2012 09:10 AM
Thanks for your answer!
I will try what you suggest.
If I don't close the file, the programm will keep writing the same data into the file. I hope the the writing would be executed once when there is a change of data, then no writing would be runned until next data comes in. The problem is I put the new coming data into a shift register for displaying. So the program will keep writing data into the file duet to shift register.
04-15-2012 10:25 AM
Then the problem is with the rest of your code, not with the file IO. Right?
Don't write the data accumulated in the shift register.
Don't write unless there is new data (case structure can help here).
etc.
Can youi show us the code with the shift register?
04-15-2012 10:41 AM
Thank you! You are right.
I think I have kind of solved the problem.
The wtriting will not be triggered until new data comes in (not from the shift register).
Now the problem is that I have to make sure the data is written into the file after it is accumulated in the shift register, cause the first written data is 0.
04-15-2012 10:43 AM
Sorry I can't attach the file now and I have no idea why.