Jump to content

Better Error Case Structure


Recommended Posts

I only thought of this after a month of programming in Java (i.e., I'm out of the LV mindset):

To my knowledge, LabVIEW case structures -- when wired to an Error data-type -- only allow two conditions: "Error" and "No Error". I need a way to handle "Error, code X" and "Error, code Y" and a default (unhandled) Error.

Right now my only solution is to nest two case structures, one to catch the error, and one to catch the code. It bothers me that I have to send so many tunnels through nested cases. :headbang:

Thanks, in advance,

--H

Link to comment

Hi Doon,

well two cases shouldn't be a big problem but here are my two cents:

The error code is a I32, In LV 8 we got the I64. Now if you have an error shift the error code 32 bits up.

with that method you could only use one case. The code looks quite complex, but if you want to seperately look for errors and codes (you could also skip the error boolean and look only at the code)

post-2399-1166036249.png?width=400

Prior to eight you could do similar things.

But I think if you only look at the error code you will get the information you want.

Ton

Link to comment
It bothers me that I have to send so many tunnels through nested cases.

Whilst I think that you're being a wee be dramatic, I agree - a native case structure with error codes as selectors would save a bit of code, and (not being privvy to LabVIEW source code) I don't think that'd be too difficult to implement (?)

Are you passing warning meesages? If not you could just use the error code case, and an error code of 0 is no error.

You could even filter warnings with a -ve case selector.

Link to comment
Are you passing warning meesages? If not you could just use the error code case, and an error code of 0 is no error.

:lightbulb: Actually, GPIB uses error code zero, so be careful with that idea.

Error 0: Error connecting to driver or device.

I have no idea what conditions make this error code be returned, but there you have it.

One of those legacy things from years ago.

Link to comment
:lightbulb: Actually, GPIB uses error code zero, so be careful with that idea.

Error 0: Error connecting to driver or device.

Yes, which idiot introduced that :angry:

I always use the attached VI called Suppress error codes.vi which removes given errors from the wire. The errors to remove/suppress are specified with an I32 array. When one of those errors has been found it is removed and a boolean indicator is set so you can respond to the error. You could then create your own error instead of the old one, or perform some action. It also removes warnings that match the given number so you can also remove for example the VISA warning for "More characters are waiting in the buffer" (of which I don't know the error code because it is specifically chosen to be impossible to remember).

Joris

Download File:post-1555-1166086583.vi

Link to comment
:lightbulb: Actually, GPIB uses error code zero, so be careful with that idea.

Error 0: Error connecting to driver or device.

:thumbup: You learn something new every day!

but I thought I had seen everything a lot in LV, but what is a '-ve case selector', I know the 8.x palettes messed with our heads but this? :blink:

:D Glad to hear I messed with your mind Ton! All I meant was:

post-181-1166121908.png?width=400

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.