LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting default Xcontrol value

I may be wrestling outside my weight class here, but I've started playing with Xcontrols.  I've made an Xcontrol that does almost everything I want.  The piece I'm missing is how to make it so that when I drop a copy of the Xcontrol in a new VI, how do I pre-define what values/settings it will appear with?  The data is a cluster of 2 doubles.  I just want to be able to specify what the doubles should be up front.  I know I can set the"State" in the "Init" ability, but where can I set values for "Data"?

 

Thanks,

Jason

0 Kudos
Message 1 of 5
(2,927 Views)

OK - I figured it out after making it much harder than I needed it to be.  I added an Init? flag to my state, which I set to true in the Init ability.  In the Data Change event, I use that flag and a case structure to set the default data value - then clear the flag.  

 

I know Xcontrols will make my code easier to maintain...eventually. (sigh)

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

Hi, i've found very useful this post   Smiley Happy Thanks!

 

I'm trying to do a similar thing, i've built an XControl: a Colored Button which color user can change pressing button itself, and choosing color from a palette

 

what i want is to pass the last color the user choosed as input to the XControl so that when the VI containing XControl loads up the Button shows the last color.

 

Is there a way to pass an input to XControl so that it can use to set its state ?

 

 

Download All
0 Kudos
Message 3 of 5
(2,684 Views)

Hi Mariano,

 

It is good to see that you have found the forums to be a great resource!  I think that your problem would be solved by programmatically making the current values the default for your front panel, is this correct?

 

Check out the following community example: Programmatically Save Current Values As Default and the following DevZone: Programmatically Making Current Values Default with VI Server

 

I think the first one is pretty straightforward and a great solution, but VI Server can also be a powerful tool as well.

 

Hope this helps!  Best,

 

Ryan C.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 5
(2,665 Views)

Thank you all for your precious answers :smileyhappy:

 

The init state i've posted was a try, so the constant values with which i unbundle-bundle previous state were intended as values to be loaded from a config file.

 

Finally i've found a way to realize what i wanted: creating a write property for my XControl, loading values from a config file and setting them at vi loading.

 

The important thing i have "discovered" is that when a (write) property node is called on the XControl, display change state is called in facade, and there DATA CHANGED in action structure must be set to TRUE  state, otherwise there is no effect.

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