Jump to content

Refnum becomes invalid if there is an error in: is this expected behaviour?


Recommended Posts

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?

error.png

setup.png

Edited by codcoder
Link to comment
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.

Link to comment

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.


image.png.2a7e8973ee887700c15d6626038c00ba.png

Is it expected behaviour? Yes. Should it report a different error code? Maybe.

Edited by ShaunR
  • Thanks 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.