LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating an array with different data types

Hi,
 
Is it possible to create an array containing different data types.  I've created an array, but it must of a single type (e.g, numeric).  An array of clusters is also possible.  However, if I want an array of different cluster types, is there a data type that can help me with this problem.
 
I'm doing this to try out the XML output in a tree format for a project.
 
Thanks
 
Will
0 Kudos
Message 1 of 18
(16,806 Views)
Each array element must be of the same datatype. Even if you have an array of clusters.

That said, what is your intended input/output? You said XML output. Can you provide more specifics?
0 Kudos
Message 2 of 18
(16,802 Views)

Hi, William,

You can build array of variants. Then each elements can have different type. You can store such array in xml format too:

hope it helps,

best regards,
Andrey.

 

Message 3 of 18
(16,780 Views)
Thanks for your help,
 
I cannot find the icon where the three values combine into one.  However, this VI seems to combine all three datatypes into one.  I'm looking at loading and reading information for an array of engines, where each engine type contains different data (for example, enginea has var1, var2, var3 and engineb has var1, var4, var5).  An array would contain and manage the data as such:
 
   - engine1 of type enginea
   - engine2 of type engineb
   - engine3 of type engineb
   - engine4 of type enginea
   - engine5 of type engineb
 
The output would only contain the variables associated with the particular type of engine.  This part could possiby be done by hand or XML encoding.
 
Thanks
 
Will
0 Kudos
Message 4 of 18
(16,772 Views)
You can also have an array of clusters where the cluster contains different data types.
Message 5 of 18
(16,769 Views)
Would this scale well if the amount of data was very large?  I don't like having a cluster with 50 variables, where I'll only be using 15 for a particular type.  I'll probably have to create functions to extract the information required for a particular data structure.  However, this may be the only way to handle it.
 
Thanks
 
Will
0 Kudos
Message 6 of 18
(16,761 Views)
The cluster can also contain arrays 😉
 
And the array of clusters would not care that the cluster itself contains arrays. 
 
However, the array(s) must be of the same type.
 
As for the size, you would have to define "very large".  But it's unlikely a problem.
 
RayR
0 Kudos
Message 7 of 18
(16,756 Views)

Hi, William,

But I still will recommend to try with variants. Its very useful if you need to handle data with different types. For example, you can add type attribute to variant, and then switch in your for loop depends from the incoming type:

 

But it depends from your architecture (probably, just array of clusters will be enough for you as Joe mentioned).

best regards,
Andrey.

Message 8 of 18
(16,749 Views)

Andrey,

I like the idea of using variants.  I think the concern about the use of variants is how they are supported in the future.  Can't remember the details...  I'll probably experiment with your suggestion.  ... it's always good to experiment...

Thanks 🙂

RayR

0 Kudos
Message 9 of 18
(16,715 Views)

i've the same problem.
i need an array with datatpes Numeric and String. please see the attachement.
 
i need to use horizontal and vertical scrollbar with the array (contains more than 20 columns). so i cant use a 1D array of cluster.

 

please send me your  valuable suggestions.

 

thanks

 

RENN 

Kudos always welcome for helpful posts 🙂
0 Kudos
Message 10 of 18
(16,472 Views)