LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

determine unused variables in labview

is there a tool in labview 8 (inc rt) to determine if any of the variables i've defined are unused (or give me a break down of where they are used?)
0 Kudos
Message 1 of 18
(6,755 Views)

Maybe, but first, what are "variables"?

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 18
(6,750 Views)
Hello Guzz,

if you refer to global variables: you can right-click the global and select 'find global references' to look for their usage... This has been in LV for years.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 18
(6,744 Views)
i'm refering to all variables i've defined in my labview 8.0.1 realtime project
i want to be able to select a variable from the project view and determine if it is used in either my remote or local host VIs
 
Message 4 of 18
(6,736 Views)

Hi Guzz,

I think you are referring to “Shared Variables”, which you are using to share data among VIs in a project or across a network.

There are various means of searching whether variables are being used in your project VIs. However, this cannot currently be done from the project view and certain methods can only be used to search whether locally stored variables are being used as do not work for remotely stored variables.

There are two ways of searching locally stored variables using the find and replace utility:

This method relies on having the variable labels set as visible items:

You need to create a blank VI within the library/project you're searching from and drag the variable that you wish to search for into the blank VI. Then click “Edit” on the Blank VI toolbar and select “Find and Replace” from the drop down menu. A “Find” Window will open. Within the window make the following configurations: for the “search for” option select “text”, in the “Type in words to search for:” selection box enter the name of the variable that you wish to search for, and for “Search Scope” select “<All VIs in Application Instance”. Click “Find”.

All the locations where the variable is being used will be listed. If no locations listed then either the variable is not being used or the label for the variable is not a visible item.

This second method does not rely on the variables labels being visible:

Message 5 of 18
(6,690 Views)

Open the “find” window as in the previous method. Within the window make the following configurations: for the “search for” option select “object”, “globals” and click on the icon of the variable you wish to search for. As explained previously the location of all variables being used will be listed.

The attached example VI, "Cluster test.vi",  has been developed by one of our engineers as a starting point for anyone who wants to develop LabVIEW code which can search for and list the VIs where shared variables are being used.

Using the attached VI, "Cluster test.vi", you can also just have an array of the variables you want to search for, rather than having to strip them from the project names as long as the names of the variables are known.

 

I have zipped up an example LV 8.0 project so that the functionality of using "Cluster test.vi" can be easily seen.

Simply run the "Cluster test.vi" and it's front panel will populate the table control listing what variables are being used and in what VIs they are being used.

 

I hope this is helpful.

 

Emma Rogulska

NIUK & Ireland

 

Message 6 of 18
(6,689 Views)

Hi Emma, I downloaded the zip file you attached but the "cluster test.vi" appears different than what you describe. Can you please re-attach?

Thanks,

Sima

 

0 Kudos
Message 7 of 18
(6,680 Views)

Hi Sima,

My apologies.

You are completely right I attached the wrong file to the post by accident.

The correct VI is attached to this posting and I have renamed the search and display VI to "find refs.vi" as it is a more logical name.

I hope this helps,

Emma Rogulska

NIUK & Ireland

Message 8 of 18
(6,661 Views)
Thanks Emma. This is cool!
0 Kudos
Message 9 of 18
(6,627 Views)
Come to use this a while later, I'm having trouble if the VIs are not included inside the library itself, but just in the "root" (under My Computer, or even in a folder). I have tried to modify the code but couldn't get ther references right. Anyone have an idea? Thanks.
0 Kudos
Message 10 of 18
(6,467 Views)