09-26-2012 11:11 AM
How do I conditionally open up a file. I am trying to use a true/false case statement, but in the false case, I have 2 errors, an unconnected error and an unconnected refnum. So I have 2 unconnected tunnels. Also, my write to file is in a while loop, so is there a consequence of writing to a file I didn't even open. I can't put my write to file icon inside the case statement with the file dialog open.
Navman.
09-26-2012 11:13 AM
@navman wrote:
How do I conditionally open up a file. I am trying to use a true/false case statement, but in the false case, I have 2 errors, an unconnected error and an unconnected refnum. So I have 2 unconnected tunnels. Also, my write to file is in a while loop, so is there a consequence of writing to a file I didn't even open. I can't put my write to file icon inside the case statement with the file dialog open.
Navman.
How do you conditionally open up a file? It depends. (Haha, a little humor there.) Actually, can you post the VI so we can better understand the issue(s) you are having?
Thanks. 🙂
09-26-2012 11:23 AM
Simply based on the limited information in your post, you want to wire the error cluster through and us a Not a Refnum Constant (found in the File palette) for the reference. At the write part, you can either perform a check for Not a Refnum (there's a primitive in the Comparison palette that does that) or simply handle the error that will ensue.
09-26-2012 12:00 PM
If you're using the file functions with a refnum you must 1st use Open file to get a refnum. If you dont need to keep writing to a file it's easier to just wire a path to write file, in which case it'll open, write and close itself. For lots of writing that's inefficient and you'll better use the refnum instead.
As for the case structure, just like you need to open a file and connect it to write file and close file you'll need to do the same when it's inside a case, the difference being that in the other case those wires goes straight through without any function.
/Y