09-29-2005 01:21 PM
You had it when you NEWed the file. You converted it to a path (I don't know why - you already had a path), and then threw it away.
It's your responsibility to hold on to the refnum and use it when you WRITE (or READ) the file, and also CLOSE it.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
09-29-2005 01:23 PM
Indeed. Consider the case where you attach an F1 keycode to your switch. Hitting F1 would then toggle your switch, but NOT trigger your event, if it's based on MOUSE UP.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
09-29-2005 01:44 PM
09-29-2005 01:52 PM
A few more notes:
Attached is a quick draft how you would carry the file name and refnum in shift registers to give you some ideas. It stlll needs work, e.g. wiring of the errors, and general code cleanup. I did not test if it even works, because I don't have your subVI.
09-29-2005 02:48 PM
09-29-2005 04:58 PM
Hi Christian,
I came across Richard's ("Broken Arrow's") accolades re: Clear Error.vi, and confess that I totally miss the point of how it functions when called as it is here - not in a chain.
09-29-2005 05:58 PM
Here it is just a bandaid solution. 😉
By default, automatic error handling is enabled and you'll get an error dialog whenever the error output is not wired and an error occurs. Here, an error occurs in the cases where (1) the refnum is not yet set AND a (2) close node is encountered, e.g. at the start of the program. Wiring the error output ensures that nothing pops up. 🙂
Error handling should definitely be improved in the example!
09-29-2005 06:27 PM
Ahhh, oK - I must have "show errors" off - but it could be useful...
Thank you!
10-03-2005 08:35 AM
10-03-2005 01:10 PM
I think good interface rules dictate that you disable and gray the button if it can't be used at the moment. This does several things:
1... Let the user know that they can't close the file (it's already closed).
2... Makes your code easier - you don't have to handle the special cases - if the button was clicked, respond to it, since you know that it can't be clicked if it shouldn't be.
Blog for (mostly LabVIEW) programmers: Tips And Tricks