LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parse array of variants

Solved!
Go to solution

I don't have much experience with Variants from "other than LabVIEW", so am not familiar with how the outputs of the Info function (Typedef and Name) are handled.  I could imagine that if you had to rely only on Type, deciding among which, say, Dbl element is which (other than assuming an order in the string) would be a problem.

 

As to your diagram, you could use the same method I used to build the cluster in the same loop, rather than changing the Array of Variants to a flattened string, then separately unflattening the string to the Cluster -- just build the Cluster (as I did) while taking apart the Variant Array.

 

BS

0 Kudos
Message 11 of 16
(1,428 Views)

Vltan, your code was almost exactly what I was looking to do. As you guessed, my data is not coming from a LabVIEW source (it's actually coming from an embedded target that serializes a C structure and sends it to my LabVIEW app for display).

 

Also, thanks to Bob_Schor for providing the initial code. Very helpful.

 

One last question: how do I generate those nifty VI screenshots that you can drag-and-drop into LabVIEW as code? Very cool.

0 Kudos
Message 12 of 16
(1,406 Views)

They are VI Snippets.  They are actually images with the VI source code embedded inside, which is why you can drop them onto a block diagram and get the actual VI.  With a block diagram selection highlighted, go to Edit -> Create VI Snippet from Selection.

 

Also, note that the code that I put together comes with no warranty that it actually operates as expected.  I had no way of testing it with non-LabVIEW sourced variants, and I do not know how that GetTypeInfo works internally.  It was just a "Here is something that looks like what I was thinking."

Please let us know if it does work, though!



Message 13 of 16
(1,394 Views)

I think there's a much simpler approach than what vltan suggested, see snippet below. No need to check the individual type of each variant in the array, just use Variant to Flattened String, concatenate all the strings, and unflatten to a cluster.

array of variants to cluster.png

Also see this idea exchange post: http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Convert-an-Array-of-Variants-into-a-Cluster/idi-p/2943...

Message 14 of 16
(1,385 Views)

@shansen1 wrote:

 

One last question: how do I generate those nifty VI screenshots that you can drag-and-drop into LabVIEW as code? Very cool.


VI snippets built into LabVIEW are okay, but they do have their flaws.

 

I highly recommend the Code Capture Tool

Message 15 of 16
(1,380 Views)

OK I realize this tread is a little older. It seemed like a good continuation of this discussion.

 

I am trying to get the information from the Kistler Channel control. Normally this would be somewhere else in the code and all I would get would be the reference to the control. When I use the code that I made I can get some of the elements from this array of clusters. I get the 1-3 elements. I can not get the 0 element. Am I missing something here?

 

Example.png

Tim
GHSP
0 Kudos
Message 16 of 16
(732 Views)