LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I copy the string portion of an enum into the string portion of a cluster?

Solved!
Go to solution

I want to do this for the an entire array of clusters.  I'm trying to use a for loop.  Can't figure out how to parse the string portion of the enum into the string portion of the cluster.

 

Alternatively, I'd be happy if I could figure out some way to tie the enum to the array of clusters, but I figure that gets problematic.

 

DH

0 Kudos
Message 1 of 5
(3,104 Views)

format into string

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 5
(3,102 Views)

OK, let's say that the enumerated type has N elements.  I want to initialize an N element array of strings.  How do I reference each string in the enumerated type to get to each string?

 

DH

0 Kudos
Message 3 of 5
(3,089 Views)

Use the "Strings[ ]" property node on the enum to get an array of strings of the elements.

0 Kudos
Message 4 of 5
(3,080 Views)
Solution
Accepted by topic author Dark Hollow

 


@Dark Hollow wrote:

OK, let's say that the enumerated type has N elements.  I want to initialize an N element array of strings.  How do I reference each string in the enumerated type to get to each string?


Easy way to do this is to use GetNumericInfo.vi, part of the Variant library, found in vi.lib\utility\VariantDataType\GetNumericInfo.vi.  Wire your enumeration to the Variant input; one of the outputs is an array of the strings in the enumerated type.

 

The more complicated way is a for loop, in which you typecast the iterator terminal value to the enumerated type, then use Format Value.  You can get the maximum value of the enumeration by casting 0 to the enumerated type, then decrementing; cast that back to a numeric and add one to get the right value to wire to the N terminal.

 

EDIT: just thought I'd add, since RavensFan's reply popped up while I was writing mine - I don't like the Strings[] approach because it doesn't work on RT targets, and I lost a lot of time once due to this trying to figure out why my code wouldn't run properly on an RT system but worked great on my development computer.

Message 5 of 5
(3,074 Views)