LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting: Create Cluster in Array from existing cluster

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

0 Kudos
Message 1 of 8
(2,600 Views)

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.

0 Kudos
Message 2 of 8
(2,593 Views)

Use the Move method on the control with the array as the new owner.  Set the duplicate input to TRUE.

0 Kudos
Message 3 of 8
(2,580 Views)

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!

0 Kudos
Message 4 of 8
(2,573 Views)

I may be missing something but heres my 2¢

0 Kudos
Message 5 of 8
(2,557 Views)

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/

0 Kudos
Message 6 of 8
(2,549 Views)

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.

0 Kudos
Message 7 of 8
(2,512 Views)

Ah!  Thanks for that.

0 Kudos
Message 8 of 8
(2,503 Views)