LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I obtain a reference to a global variable?

I wish to change the contents of the columns in a global multicolumn listbox. As far as I can see, the only way to access the columns in a multicolumn listbox is to create a reference to it and access the ItemNames property. But how can I create a reference to a to a global variable?
0 Kudos
Message 1 of 18
(9,433 Views)
Hi,

For changing the contents of any gloabal variable, you have to access that global variable in a normal vi. Open a new vi, go to Block diagram -> Function Pallete->Structure-> Global variable. Then right click on this global variable-> replace by your global variable vi or create a new global variable vi. By doing this, u can access the value and can change it.

Hope it helps. Your feedbacks are welcome.

Best Regards,
Nirmal Sharma
0 Kudos
Message 2 of 18
(9,433 Views)
Thank you for your answer.

I know how to use global variables in general, but the problem is that a Multicolumn Listbox (MCL) referred as a global is just the number of the selected line(s). I would like to access the contents of the MCL, which I perceive as a table. If this is a MCL in a normal VI, I can create a reference (and by this I mean a reference, not a local variable), and use a property node to access the ItemNames property, which gives me the contents of the table (I could of course also have created the property node directly, but the reference can be passed to subVIs).

However, if the MCL is a global variable, it is unclear how I can create a reference or property node to access the contents. Is this impossible, or is there
something that I overlooked?

Martin
0 Kudos
Message 3 of 18
(9,433 Views)
You can open a reference to a global as if it is a normal VI and then get a reference to a control on that VI. I have included a little VI here with a test global variable to get the item names from an MCL in that global. I needed the MCL in the main program just to force the reference to a strict MCL reference. You could turn this into a sub VI that just returns the item names of a named MCL if that works better (then the MCL that's only used for reference would not be on your main front panel).

This VI searches through all the names of the controls on the referenced VI until it finds the one that's asked for.

Have fun with it.

Rob
Message 4 of 18
(9,433 Views)
An excellent answer. Exactly what I was looking for. I had wondered if it could be done along those lines, but did not know enough about the "To more specific class" function to nail it myself.

Pity that it is not possible to do this directly (i.e. right-click a global variable and select "Create > Reference" or "Create > Property node").
0 Kudos
Message 5 of 18
(9,433 Views)
Hint: an excellent answer provided with a working example certainly worths a ****! (it's four stars rating... not "censored" ¦¬)
It may not be the solution you expected but it is not the poster's fault after all...


LabVIEW, C'est LabVIEW

0 Kudos
Message 6 of 18
(9,433 Views)
Hi Martin,

Why do you require reference to global variable when it can be accessed directly. I mean is there any advantage by using reference method. I think if u eloboarte your consequences, we can share better.

Regards,
Nirmal
0 Kudos
Message 7 of 18
(9,433 Views)
Hi Robert,

Pretty excellent answer!!!!!!!!!!!!!!!!

Nirmal
0 Kudos
Message 8 of 18
(9,205 Views)
Agreed - in my (twisted?) mind I was just leaving the **** for a more simple, elegant way to do it - if such a method existed. But you are right, it is certainly not Rob's fault that NI has made it so cumbersome to do. I am therefore upgrading my rating to **** (I'm not sure I can remove the previous grading, but I'll try to add a few ****s more... 🙂

Martin
0 Kudos
Message 9 of 18
(9,434 Views)
Well what do you know - I could upgrade my rating 🙂

Martin
0 Kudos
Message 10 of 18
(9,434 Views)