09-20-2016 05:16 AM
Hi all!
I'm wondering if there is a way to dynamically get the VI name of a global variable or, in other words, the name of the VI which the global variable belongs to.
Thanks
Marco
09-20-2016 05:46 AM
Marco,
sorry to ask, but:
What is the exact purpose of it?
As variables are bound statically (before compilation), the developer conciously selects the variable. Double clicking the border of the variable will automatically open the 'global VI'.
Also note that best practices recommend unique names for everything (variables, VIs, inputs, ...). Following this recommendation results in the situation that the developer knows the exact 'global VI' already simply by reading the variable name.
Norbert
09-20-2016 08:26 AM
You can drop a global onto a Static VI Reference, then use that to get all the info about the global VI.
The only info you can get from the wire coming out of a global is the data type and the data value.
09-20-2016 08:33 AM
Hi Norbert,
don't worry about your question. In my app i use several global VIs containing lot of controls (representing global variables). During the creation process, i didn't take care about univocally name these controls, i only took care about univocally name the VIs. For exemple, for two different devices, i used two global VIs named "device1_globals.vi" and "device2_globals.vi". Inside both of these VIs, there's a control named in the same way ("Used").
I've no problem at all using this approach and i think it's clearer than naming the controls in the same way as done for the VIs.
The question is quite simple and it came out after i installed the OpenG package and saw that it contains a VI that allows to get all the strings of a typedef enum by plugging a local variable of the same typedef enum to one of its inputs. These strings are clearly static cause they belong to a typedef.
Any ideas? Thanks!
09-20-2016 08:49 AM
Paul already provided the answer. Important is that you have to select the "Static VI reference" (Application Control palette).
[...]that allows to get all the strings of a typedef enum by plugging a local variable of the same typedef enum to one of its inputs. These strings are clearly static cause they belong to a typedef.[...]
There is imho a different use case behind that VI. However, you have a solution by now so you should be able to proceed with whatever you are doing 😉
Norbert