LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Update variant value and keep type def info

Solved!
Go to solution

Is it possible to update the value of a variant control and preserve its type defintion? I tried using the "Set Type Information.vi" in the Data type parsing palette but in that case the value is set to default.
(Attached VIs: test of updating an enum from a numeric or string which is the use case I'm looking for)

Download All
0 Kudos
Message 1 of 4
(1,566 Views)
Solution
Accepted by topic author hunkel

Only thing I can think of is that if you flatten the Variant to a string, then flatten the new value to a string as well, you can then parse the first string to find the location of the value within it, then replace that value with the new one, then unflatten it back into a Variant.  If you look in the help file for the flatten function it does describe the format if you want to try it.

 

However, doing this seems like a pretty weird thing to need to do.  Can you maybe state the general problem you're trying to solve?  I can't think of many situations where preserving the name of a type definition in a Variant while changing its value would be the ideal solution.  It seems there's a good chance that using an alternate solution such as a VIM, or a data type other than Variant, might be better.

0 Kudos
Message 2 of 4
(1,502 Views)

Maybe you want something like this.

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

Thanks Kyle97330, I don't know why I didn't think of Flatten to string but that worked of course (solution attached).

 

In short, I'm using this to let users specify custom filter criterias (in e.g a text file) to select variables from a "variable db" and where the variable properties are stored as variant attributes (and some properties are in this case type definitions).

 

0 Kudos
Message 4 of 4
(1,389 Views)