04-17-2012 03:50 PM
I want to build a subVI to perform some array operations - regardless of what the arrays are, how do I make a subVI to accept an array of any type? The array's I'm passing are array's of clusters...and I have over a dozen different array's of clusters.
This would be similar to most of the array functions built into the LV pallett that accept any type array.
Any thoughts?
04-17-2012 05:36 PM
Look at Polymorphic VI Window.
http://zone.ni.com/reference/en-XX/help/371361H-01/lvdialog/polymorphic_vi_dialog_box/
A polymorphic VI is basically several VIs all in one subVI. Based on the data type passed in it will select the VI that matches the data type.
This may be a good starting point
http://zone.ni.com/devzone/cda/epd/p/id/3229
04-18-2012 09:20 AM
I'm familiar with polymorphic VI's, however I don't see how they would save me time. I'm dealing with rather complex arrays of clusters. I would have to create an instance for each type of cluster I've made, and would have to create new instances every time I make a new array of clusters.
Within my subVI, I don't need to perform operations on data within the elements, I just have to be able to select and/or reorder elements. That's why I want a generic input/output type.
Ex...the built in "Index Array" fuction in Labview accepts any type of array, yet it doesn't "know beforehand" what my array of clusters looks like, and certainly doesn't contain cases to handle every possible array of clusters. How is that done?
04-18-2012 12:58 PM
Can you convert it to varient and pass that in? You can covert back to native type inside subVI.
04-18-2012 01:00 PM
wrkcrw00 wrote:
Ex...the built in "Index Array" fuction in Labview accepts any type of array, yet it doesn't "know beforehand" what my array of clusters looks like, and certainly doesn't contain cases to handle every possible array of clusters. How is that done?
It's done by being a built-in function - a fundamental part of the language - rather than constructed out of other LabVIEW components. There's not a lot you can do easily to duplicate it. However, if you just need to accept an array of any type but do not need too much access to the data contained in individual elements, you can create a control that is an array of variants, and wire an array of any type to it. You could then extract a subset of elements, for example, and return them as an array of variants, then convert that back to your desired data type.