From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build Array of Contents in Variant

Solved!
Go to solution

Is there an easy way to take a variant that might contain anything and output a variant that contains an array of that thing?

Clipboard.png

Build array won't work because it will yield {Array{Variant{Thing}}} and what I need is {Variant{Array{Thing}}}.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 1 of 8
(3,111 Views)

What kinds of "things" are you talking about?

 

The key point of arrays is that every element must be of the same type.  So if you want an Array{Thing}, then every Thing in that array must be the same type of Thing.

 

 

0 Kudos
Message 2 of 8
(3,109 Views)

What about using variant attributes? They allow you to create arbitrary lists of anything.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 8
(3,107 Views)

Not "things", "thing".  The "thing" could be anything.  I have an incoming variant that might contain anything (I don't have any control over it).  I want to build an array of that "thing" and put it into a variant.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 4 of 8
(3,099 Views)

Since the thing is a variant, and you want to put an array of those "things" into a variant, it sounds like you want a Variant{Array{Variant}}.

 

Capture.PNG

0 Kudos
Message 5 of 8
(3,087 Views)

@RavensFan wrote:

Since the thing is a variant, and you want to put an array of those "things" into a variant, it sounds like you want a Variant{Array{Variant}}.

 

Capture.PNG


Not quite.  The "thing" is not a variant, it is what is inside a variant.

Your code produces a variant of an array of variants of things.

I want a variant of an array of things.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 6 of 8
(3,046 Views)
Solution
Accepted by topic author paul_cardinale

As happens not infrequently, the solution came to me as I was laying in bed waiting to fall asleep.

bv.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 7 of 8
(3,043 Views)

That usually works, but it gags if the "thing" is an array (because it tries to put an array in an array).

It should act like "Build Array", and if it gets an array as an input, just add another dimension.

Here's the fixed version:

bv.png

Note: This doesn't pass any data along, it always outputs an empty array (for my I app, I only need the variant to contain type info).

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 8 of 8
(2,973 Views)