LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unused Code - VI Analyzer

Solved!
Go to solution

So when using the VI Analyzer I'm being told that I have a segment of unused code and am wondering if this is not the way to perform the operation I'm wanting. I am pretty sure that the segment of code is indeed used, but perhaps the issue lies within the way that I'm attempting to accomplish this. I am trying to turn off/on menu items as the program runs/stops. When auto-indexing an array into a for loop can that be done twice with the expected results?

 

If I have 2 arrays, with 2 items in each array, and those are going into a FOR loop. Will that FOR loop run twice and pull both the first items in the first iteration, and both second items in the second iteration? 

 

A picture it probably a better way to illustrate this. 

 

error_unused_code.png

 

I'm being told that the string constant "Instruments" is unused code. Please help me understand why that is?

 

0 Kudos
Message 1 of 3
(2,913 Views)
Solution
Accepted by rkmadse

I have not looked into the method VI analyzer uses to detect dead code, but the compiler is building array constants and silently replacing your constants+build array with simply the built array constants.  I'd suggest you do the same, use array constants on the BD instead of building an array of constants.

Message 2 of 3
(2,900 Views)

The right border of the constant seems thicker, so I'm guessing you have two constants there - one which is wired and one which isn't and that's the unused one. Another example of why I don't like hidden code.

 

In general, I believe you should also be able to double click the result in VIAN to have the specific piece of code selected and then you can move it using the arrow keys and see how it behaves. It's also helpful to turn on warnings or clean up VIs to find things like this.


___________________
Try to take over the world!
Message 3 of 3
(2,893 Views)