LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ASSERT's in LabVIEW?

Is there anything equivilent/similar to the C "ASSERT" statement in LabVIEW? FYI - the C "ASSERT" statement accepts a conditions (i.e. i>3) and if it's false, an error is put out and execution stops. Example: i=1; ASSERT( i>3); would fail, print an error, and halt execution. The CVI equivilent is DoAssert from the toolbox.h
 
Thanks
"Lockheed" Joe
Testing Blog"
0 Kudos
Message 1 of 6
(3,388 Views)
I have not come across any built in function like this, but it seems like it would be straight forward to build a function that does the same thing and use it as a subvi in your software.  The only hurdle I see is that you would need a new vi for each ASSERT condition (or each type of ASSERT condition).  Maybe someone else has come across this before and give a better solution.

Cheers
0 Kudos
Message 2 of 6
(3,382 Views)
I saw the same type of problem of having different VIs for each type of output data. I was hoping there was an easy way (i.e. built in way) of doing it.
"Lockheed" Joe
Testing Blog"
0 Kudos
Message 3 of 6
(3,377 Views)

The concept of aborting a program because some condition occured sounds terrible. Why not handle the error correctly?

This is even worse in LabVIEW because the code is 2D - you can't stop execution at an arbitrary point in time.

That said, you can always write it explicitly in code using the Abort VI primitive. Alternatively, you can just avoid wiring the error clusters and the automatic error handling will do exactly what you want (and will even let you continue).

Can you provide an example where something like this would be desirable?


___________________
Try to take over the world!
0 Kudos
Message 4 of 6
(3,370 Views)
Asserts are used for debugging. I use them when there is an error that only happens occasionally, say once every few hours of constant running. Yes, I could have an some type of error handling, but why? Once I find out the problem and fix it then the error handling would be removed anyway.
 
I've used it a lot and it's always been very useful.
 
As far as the 2D code in LabVIEW...well, I'm just a beginner LabVIEW programmer and I have several times needed something like an Assert. I've found the Data driven paradigm of LabVIEW easy to write, harder to debug.
"Lockheed" Joe
Testing Blog"
0 Kudos
Message 5 of 6
(3,363 Views)
I think what you want is a conditional breakpoint. These have existed since LabVIEW 7.0 and are very useful. I think you can even write them yourself. Try it by placing a probe on a wire (e.g. a numeric or an error). If you use the conditional probe, you get a second tab which allows you to stop it on conditions. Of course, you still need a probe for each data type, but the basic ones exist.
 
Conditional breakpoints are useful, but in general, if you have a potential for error somewhere, you should handle it, not assume that it will disappear forever just because you fixed the code. It is true that error handling complicates your code, but that might be the price you have to pay for robust code. If the error surfaces after the application has been compiled or because some other programmer did something stupid, you might have a hard time detecting the source of the error.

___________________
Try to take over the world!
0 Kudos
Message 6 of 6
(3,340 Views)