01-16-2014 04:09 PM - edited 01-16-2014 04:10 PM
I am creating a custom programming tool to generate some custom LabVIEW TypeDefs.
One of the structures I have to create is an array of clusters; but from an existing cluster. That is, I have a reference to a previously defined cluster, and I need to array this.
One possible way to do this is to duplicate the cluster next to the empty array, and then 'move it into' the array. This seems to be an ugly solution.
Is there a better way? When I try and use "Create from Reference" method, the cluster is created in the array, but the sub-elements trigger error 0x421: Type Mismatch.
Thanks!
Jed
01-16-2014 04:21 PM
That's what I would do. It is basically what you would do if you were doing it manually on a block diagram rather than programmatically.
Without seeing the VI, it is hard to help with that error message. If I had to guess, maybe the wrong reference is being used in trying to create the new cluster in the array.
01-16-2014 04:45 PM
Use the Move method on the control with the array as the new owner. Set the duplicate input to TRUE.
01-16-2014 04:52 PM
I don't want to duplicate, as the reference is coming from another VI entirely, but I will copy it to the VI first, then move it in there. Thanks!
01-16-2014 07:16 PM
I may be missing something but heres my 2¢
01-16-2014 07:50 PM
Hi Viper,
Sorry- you misunderstand. We are talking about doing this with LV Scripting; what you did statically defines the array type in the VI. Writing LV code that would create the array from an undefined array by running a VI. (In the situation above, the code would actually EDIT the VI and change it's functionality)
There are a few examples in the distro if you search for "scripting", but here's a page with some example code you can look at.
http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/wiring_scripting_objects/
01-17-2014 08:06 AM
The Move method works across VIs. No need to copy it to the other VI first. It is a programmatic way of dragging a control, whether that is in a single VI or from one VI to another.
01-17-2014 09:54 AM
Ah! Thanks for that.