LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert an array of string elements to a cluster with named elements of different datatypes?

Solved!
Go to solution

I'm looking for some help with converting an array of string elements into a cluster with named elements of different datatypes.  

 

I'm importing data from an Excel spreadsheet.  It is coming into LabVIEW as 3 separate arrays (of Strings): 1) Variable name, 2) Datatype (three possibilities Int, DBL, String) and 3) Value, with the indices in each array corresponding to a separate variable (I have approxiamtely 180 variables to import).  My end goal is to convert the "Value" string array into a cluster.  But I want the datatype to be correct in the cluster and I also would like the name of the elements in the cluster to correspond with the "Variable Name" string array so that I can use the Unbundle by Name function in my main VI.

 

Please see the attached a SubVI for more details.  I made the size of the imcoming arrays 5 elements for simplicity.   I realize that owned labels cannot be changed during runtime and I don't think that I need to do this.  I just want to use the output cluster (mostly the unbundle by name) to help with designing my main VI.  I will need to 'read from' and 'write to' the cluster during runtime but I will not need to change the element names.

 

I was also wondering if there a better way to import the data from Excel?  Is there a way to import directly into a cluster right away rather than bringing everything in as strings?  I've attached a SubVI showing how I am currently bringing in the data (found it on the forum somewhere).  It comes in as a 2D array, which I split into the 3 separate arrays that I mention above.

 

I'm open to any and all suggestions.  Thank you very much.

 

-Mike 

Best regards,
Brown

The more I know...the more I don't know
0 Kudos
Message 1 of 3
(3,833 Views)
Solution
Accepted by topic author Brown@KTR

Instead of trying to create a cluster, I think I would just use Variant Attributes.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 3
(3,793 Views)

Thank you.  I have never used variants before so I am new to this concept, but I can make this work.  It will take a little more work on the back end to pull the right variable (rather than just selecting from the unbundle by name function) but that's ok.

 

Cheers,

Mike 

Best regards,
Brown

The more I know...the more I don't know
0 Kudos
Message 3 of 3
(3,773 Views)