Minneapolis LabVIEW User Group

cancel
Showing results for 
Search instead for 
Did you mean: 

Follow-up on the VI Analizer

At this evenings LUG meeting Jed demoed the VI analizer.  I want to add my enthusiasm for this tool.  I feel it has made me a better LabVIEW programmer.  I also want to point out a few ini. Options that work alongside the VI analizer that help me realize when I'm writting "Bad Code"  Between these options and VI analizer you just may prevent a "I could have had a V-8" (AKA "Face-palm") moments.

First our LabVIEW ini options.

Tools>>Options- Block Diagram- Constant Folding:

Show Constant Fording of Wires

Show Constant Folding if Structures

Check them both!  The Constant wires will "Squiggle" the Constant Structures will "Hash"

This will key you into when you actually create something that cannot change during run-time. For example 

aConstStruct.png

Numeric = 1  the optomizer in the compiler will replace this code with a constant and this loop will not really run.

But worse than writing "unoptomized code" some of us write code that is just plain bad. Most often by accident but, sometimes because we did not really understand what the code we took over really did do.  The Code we inherited might have been "richly obfuscated."

So lets do a work-along. (In Shortcuts to keep it quick if you please)

From LabVIEW:

Ctrl+n (New Vi)

Ctrl+e (Show Block Diagram)

Crtl+Space (Open Quick-Drop)

TD (Select the 7th on the list TDMS File Viewer)

Click on the BD to drop TDMS File Viewer.vi

Select TDMS File Viewer.vi and Ctrl+ double-click to open its Block Diagram.  You should see this:  (Adjust for the diferences between a screenshot and the snippet tool)

AATdms.png

Yes I chose this vi from vi.lib because it does have critical errors.  Make no mistake- it is functional code!  NI even documents its behavior and functionality! (There are vi's hidden deep in vi.lib that are even more useful, some have bugs)

Now, lets run the VI analizer and see if we could do better.......

Tools>>VI Analiizer- select

analize the current vi- Select Next

Select - Analize-  Refill your coffee- its worth it.........

Now- at home I do not have the entire TK.  How many of you see the "Dead Code" lower left on the event structure (The error tunnel is not wired outside the event case)  subvIs viewed as vis rather than icons?  Those tall yellowish things are vis- (Right-Click them and check the default "View as Icon."  Did you know that is a vi?)

Are those terminals with the same label?

Yup- all easy mistakes to make-  VI Analizer does not make those mistakes.


"Should be" isn't "Is" -Jay
0 Kudos
Message 1 of 1
(3,826 Views)