codcoder Posted December 20 Report Share Posted December 20 (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 December 20 by codcoder Quote Link to comment
drjdpowell Posted December 20 Report Share Posted December 20 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 Saturday at 12:37 PM Report Share Posted Saturday at 12:37 PM (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 Saturday at 12:45 PM by ShaunR 1 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.