LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

xcontrol default value

I've been making my first several XControls and I have an issue that I cannot figure out.

I have an array in one of my XControls which is supposed to always have 4 elements in it.  The problem is that even if I create the type defs with 4 elements and have it set to the default value, when I drop the XControl in a VI, the array is empty.

As far as I can tell, everywhere I can think of where the XControl may get its default value has the array of 4 elements set as the default value.  I have attached a small example which illustrates my problem.  The Data is a simple 4 element array of {1,2,3,4}.  The Fascade only displays the Data on a Data Change event.  A pop-up will display whenever a Data Change event occurs.

My expectation is that I drop the XControl on a VI and get a Data Change Event and the array indicator would show the default value of the Data type, i.e. {1,2,3,4}.  WHat I get is a Data Change Event, and the arry is empty.

I appreciate any help I can get.


Message Edited by Matthew Kelton on 03-17-2008 02:54 AM
0 Kudos
Message 1 of 6
(4,005 Views)
You could modify Array - Facade.vi like in the attached example to initialize the Xcontrol with the default values.
0 Kudos
Message 2 of 6
(4,001 Views)
I guess that will work if needbe.  You need to update the Data Changed Display State.  My control is a bit more complicated than my example.  I have some one-time init stuff going on in it already, I guess I can add it in the init state.

It just seems silly that it would not automatically drop with the default data of the typedef associated with it.
0 Kudos
Message 3 of 6
(3,998 Views)
Try this.
 
Place the same 1D array in display state cluster (Array-state.ctl under project).
 
In your XControl project, there should be a  VI called Init.vi. This vi runs whenever you drop an XControl for the first time. Pass your default values to the array inside the display state cluster.
And in data change event case of the facade VI, you can pass the array from display state cluster to the Array indicator. 
 
Hope this helps.
 
0 Kudos
Message 4 of 6
(3,985 Views)
Yes, in the init facade VI, you should set this value.

To detect whether you have a drop, check the previous version cluster, if that is 0.0.0.0 you have an initial drop event.

Changing the default version of a TD and hoping it is applied to all clients is a bad idea.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 5 of 6
(3,977 Views)
Thanks for the info.

It wasn't that I had existing XControls where I was trying to update the default after the fact.  I was expecting it to work like typedefs.  If I set the default value of a typedef and drop a control of that type, it's default value is that of the type def at the time the control was dropped.
0 Kudos
Message 6 of 6
(3,975 Views)