From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

using references in X Controls

Solved!
Go to solution

I’m creating an X Control from two LabVIEW controls and would like to use references to these LabVIEW controls in the X Control’s methods.

 

My first attempt is to use the X Control’s “Display State” to hold these references. I’ve attached some example code that demonstrates this not working if you run “Test X Listbox.vi”.

 

I set these two references in the “Data Change” event case in the Facade.vi, but when I try to use these references later in a method, they are not valid.

 

How can I get these references when I’m using an X Control?

 

0 Kudos
Message 1 of 5
(2,885 Views)
Solution
Accepted by topic author bmihura

If you're changing the Display State cluster in a event case like you are doing for the Data Change case, you need to set the "State Changed?" boolean from the Action cluster to True so that LV applies the changes 🙂

 

Here is good template to apply when you need to store a control reference in a XControl state. This piece of code must be inserted before entering the Façade loop. Also, Data Change is not the best case for this kind of code, better would be Display State Change 🙂

Init Facade with Ref.png

 

Regards,

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

Message 2 of 5
(2,846 Views)

Thank you, that worked perfectly! Smiley Very Happy

 

Two questions:

 

  1. Why do you use the In Place Element Structure?
  2. And why should that code happen before entering the Façade Loop instead of in just one case?
0 Kudos
Message 3 of 5
(2,830 Views)

In place avoids making data copies during the execution - http://www.ni.com/white-paper/6211/en/

 

And because the façade VI does not execute continuously, you don't really know which events will be fired according to your interactions with the XControl. Adding the code before the while loop or inside the timeout case (which I don't prefer because this case is not meant for this) is the best way to make sure it's executed every time Façade executes.

 

Hope this helps 🙂

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

Message 4 of 5
(2,824 Views)

All that made perfect sense. Thanks!

0 Kudos
Message 5 of 5
(2,815 Views)