This site uses cookies to bring you the best experience. Find out more
Skip to main content


A VI Analyzer test that can save you from hair loss

Before I get to the main topic – let me ask you a question. What is wrong with this code?

The answer is pretty obvious, but for me, only after a few hours of wasted time. I believe this could have been a question on the CLAD, wait a minute, am I not a CLA? Shame on you! Ok, it is not time for the answer yet so keep thinking or read further.

The above code, although nothing to do with the error, it was the root cause of a lengthy debugging session for some code I was refactoring a few months ago. I was making changes in multiple places before starting testing. I have a better routine for refactoring now, but that’s a topic for another post. The refactored code worked most of the time but sometimes gave me odd results.  I had two options, revert all my changes or debug the code. I chose the second option. Time wise that was a bad idea, but if I didn’t do it, I wouldn’t learn anything.

So what took me so long to debug it? Well, the fact the above code completely ignored the error. I was 100% convinced that it would pass an error received on to the error out, I didn’t get anything so kept looking in other places.

After coming back to where I initially thought the error was, my first guess was right, but why wasn’t this reported?! I kept digging and following error wire until I got to the VI like the one above… So what was wrong? Dawid go back to Core1! Most of the time LabVIEW code will pass through an error from left to right via the error terminals. The problem occurs when it is passed through a For loop and the iterations are controlled by the number of elements in an array wired to the For loop executes. A For loop will not execute if there are 0 elements in that array and the error value will not be passed to the error out. How to deal with it, use shift registers!

At that time I only used VI analyzer for some minor style checks and promised myself that I would create a VI analyzer test for checking error wires. Fortunately enough, after having some time to spare, I discovered that this function is already there! Thank you NI!

The test is called For Loop Error handling and it can be found under Blog Diagram/Warnings

This is the information you will get if the error handling is not implemented correctly. Quite descriptive provided you have got VI Analyzer in place and a bit of extra energy to read it in full.

I use much more VI Analyzer tests now but I don’t use it in full, I rather try to find the most useful features. For those like me trying to get the most with minimal effort I would also suggest including the ‘Error Cluster Wired’ test that checks if the error output of the VI is passed further. I didn’t waste time because of not having this other one but who knows what would happen if I didn’t use it. Error handling is a very important topic for me so it is really nice we have got a tool like VI analyzer.

What are the VI Analyzer tests that you rely on? We would love to know so that we can improve our test coverage!


Back to Blog listings


Call 0121 318 6363 to discuss your requirements