codcoder Posted Friday at 07:44 AM Report Share Posted Friday at 07:44 AM (edited) Hi, So I had a bug I couldn't figure out. The setup is according to the attachment. The Close File function kept throwing an error (code 1) and I couldn't understand why. But then I finally understood: if there is an error in to the Write to Text File the file refnum becomes invalid. The reason I am starting this thread is that I always thought that there is always a case structure in a sub VI, even for the primary functions, so that if there is an error the function isn't executed BUT any refnum passes the VI unaffected. But that isn't the case? Is this an expected behaviour? Edited Friday at 07:44 AM by codcoder Quote Link to comment
drjdpowell Posted Friday at 03:11 PM Report Share Posted Friday at 03:11 PM 7 hours ago, codcoder said: if there is an error in to the Write to Text File the file refnum becomes invalid I just checked, and it doesn't close teh file reference, but it does pass out a null reference. The original reference is still valid. This is still unexpected behavior, though. Quote Link to comment
ShaunR Posted 16 hours ago Report Share Posted 16 hours ago (edited) You are probably getting a permissions error on the Open (windows doesn't ordinarily allow writing "c:") which will yield a null refnum and an err 8 on the open. Your err 5000 becomes a noop as does the write. You're then clearing that error so when you come to close the null refnum it complains it's an invalid parameter - equivalent to the following. Is it expected behaviour? Yes. Should it report a different error code? Maybe. Edited 16 hours ago by ShaunR Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.