03-31-2010 04:06 PM
I want to implement a queue for practice (even though i know it already exists). So, one operation i need to perform is to insert an array into another one, but i want the arrays to be any type, of course both arrays have to be of the same type. Now, if i just attempt to use empty, 'void' arrays and wire them to 'insert into array', it complains : 'you have connected to a polymorphic terminal that cannot accept this data type.'
Now, i know there exists polymorphic vis, but I want to be able to append any array of a certain type to any other array of that same type. Im certainly not going to right a vi for each data type i want to be able to insert! I thought i would just be able to use polymorphic operations built into labview and somehow specify that the elements are going to be the same type, i event tried 'type cast', but still same message.
How do i do this?
03-31-2010 05:21 PM - edited 03-31-2010 05:22 PM
What do you mean by "void" arrays? Are you referring to an array construct that has no element in it?
You could try using variants. In other words, your VI would have an array of variants as the inputs and output. Of course, this would require using the Variant To Data function on the output side. For example, this is appending an array:
and its use with two different datatypes:
All of this would add memory and CPU overhead. For practice it's fine, but not something I would do for real-world use.
What I don't understand is whether you're actually trying to replace the array functions. If so, this doesn't make much sense, since these functions are already polymorphic.
03-31-2010 05:41 PM
Heres what im trying to do:
I want to input 3 things to my subvi:
An array of an arbitrary type
An integer specifying the max size the array can be
a single piece of Data of the specified array type
Then, I want to push the data onto the beginning of the array. If the array size is still less than the max size, then just return that array. If the array size is bigger than the max size, than i want to just take the first n items (where n is max size) of the array, and return that subarray.
The problem is getting the 'arbitrary type' in. I created an array control which i input into the built in 'insert array' vi. However, this vi forces the array to have a type - i do not want this, i want the user to be able to specify the type. So, i want an equivalent of a 'void type', like in c.
04-01-2010 03:46 AM
LabVIEW doesn't have any official support for type propogation, other than for class wires, nor does it have a convenient interface for creating and editing polymorphic VIs, thus leaving us at a problematic spot.
The only way to do what you want today is using XNodes, which are not supported and which you can't get easy access to.
I suggest you vote for this idea to help push this request further in future versions.