02-05-2018 04:44 PM
I was looking to create a quick drop to search my project for calls to a shared variable. I believe that I would need to search the project by the variable's name to find the point-of-use within VIs.
My first attempt can see that it is a shared variable, but I can't find a way to get it's name. At the very minimum, I would like to copy the name to the clipboard.
02-05-2018 04:50 PM
You can read the Label.Text property of the Shared Variable node. It will always be the target namespaced name of the variable, like "My Computer\abc.lvlib\Variable1".
Also, you should consider implementing this feature as a Right-Click plugin instead of a Quick Drop plugin, since right-click plugins are more suitable for more context-sensitive operations, like operating only on certain objects.
02-05-2018 05:10 PM
As an alternative you could just do a text search for the name of the shared variable using the search window that already exists. Just "CTRL+F". Works really well. I had to re-architect an application with hundreds of shared variables and got through it that way.
02-06-2018 06:39 AM
wrote:
As an alternative you could just do a text search for the name of the shared variable using the search window that already exists. Just "CTRL+F". Works really well. I had to re-architect an application with hundreds of shared variables and got through it that way.
That is a great tip! The end result is what I was hoping to achieve. This is likely to be my final solution.
02-06-2018 06:54 AM
wrote:
You can read the Label.Text property of the Shared Variable node. It will always be the target namespaced name of the variable, like "My Computer\abc.lvlib\Variable1".
That is what I was looking for. If I just use GObj, I can only get the class name. If I cast it to a Variable, Label.Text isn't available. If I cast it to a control, Label.Text is there, but doesn't show anything.
02-06-2018 11:51 AM
I was referring to the Label.Text property of the SharedVariableNode class...I had assumed you were referring to shared variable nodes on the block diagram.
02-07-2018 08:19 AM
wrote:
I was referring to the Label.Text property of the SharedVariableNode class...I had assumed you were referring to shared variable nodes on the block diagram.
OK, now I found it. I just needed to enable VI Scripting to see it.
Now that I have the string I need, how would I pass it into "Find and Replace..." or go straight to "Search Results"?
02-07-2018 11:41 AM
2ndTime wrote:
Now that I have the string I need, how would I pass it into "Find and Replace..." or go straight to "Search Results"?
Unfortunately, there is no G interface to the Find and Replace feature.
02-07-2018 11:48 AM
Unfortunately, there is no G interface to the Find and Replace feature.
OK, thanks for the info. I appreciate it.
02-07-2018 11:53 AM
One workaround I've employed is to use the VI Analyzer to write a test that not only finds particular objects, but also uses scripting to modify the VI. I talk about this technique and give a demo toward the end of my VI Analyzer presentation.