LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modifying Variant constants

Solved!
Go to solution

I've inherited some code that uses Variant constants that have data in them. I wasn't aware this could exist. I attempt to double-click on one of the variant constants, and cannot modify any of the contents. My ultimate goal is to change one of the "FALSE" variant data to be a "TRUE". Strangely, these variants don't seem to have a Name associated either. It seems like the code is feeding in a hex value and retrieving the variant data somehow without a name.

 

Anyone know how I can modify these variant constants? Snippit and .vi attached. Code is in LabVIEW 2014.

 

Thanks for your time, -Andy

Download All
0 Kudos
Message 1 of 15
(4,424 Views)

That is very interesting.  What you are looking at is a Variant Constant with a lot of Attributes defined, but none of them appear to be named (so it's very unclear how you modify them).  You can create them yourself by playing around, but I haven't figured out how to create an attribute for an "empty" tag -- when I try, I get nothing, and if I use a space, I get ' ' instead of '' as shown on your example.

 

The fact that this variant is named DTC Dictionary is also a clue.  I've seen people suggesting using Variant Tags as a form of Dictionary/Lookup.  Search for this, and maybe you'll find something that can shed more light.

 

Bob Schor

0 Kudos
Message 2 of 15
(4,417 Views)

Watch this video at around the 38:30 mark to see our very own Altenbach giving a presentation on using Variant attributes as a dictionary lookup.

 

I imagine that to alter them you'll have to do something like this:

1. Copy them to a new VI

2. Change them to controls

3. Write code to modify them

4. Have that code wired into Variant indicators

5. Run the code once

6. Convert those indicators into constants

7. Move those new constants onto the block diagram of the current VI.

0 Kudos
Message 3 of 15
(4,403 Views)

The only problem is that all of the Attribute names are an empty string!  Looking at the Variant functions, weird things happen when you specify an empty string.  It may be hidden in there somewhere, but we need Altenbach, Himself, to lend a hand here ...

 

Bob Schor

0 Kudos
Message 4 of 15
(4,394 Views)

The names aren't empty strings, they're the result of whatever the "SPN" shifted 8 bits and then logically OR'ed to the FMI as a U32 is, and then that converted to a string.  They aren't ASCII characters you can read, but they're not blank either.

Message 5 of 15
(4,392 Views)

 

So, I would do this to replace the #19 FALSE with a TRUE 

 

 

modify-variant-constant.png 

Message 6 of 15
(4,361 Views)
Solution
Accepted by AndyEngines

You can get all attributes if you don't wire a name and can create a list as follows (same for the other variant). Find the attribute name you want to change, the rewrite the attribute to get the changed variant.

 

GetAttributes.png 

Message 7 of 15
(4,347 Views)

Hi, thank you very much for your input. I figured it out only moments before your reply. I think your reply would also work. I really appreciate you taking the time to look at this.

0 Kudos
Message 8 of 15
(4,337 Views)

Thanks Alexander. This was super helpful. Between this and the fella above who helped me realize they were not empty, i was able to build a working solution. 

0 Kudos
Message 9 of 15
(4,336 Views)

Thank you very much, Kyle. Your making me realize that the first component was not empty ended up helping me figure out a solution. Thank you so much for your time.

0 Kudos
Message 10 of 15
(4,335 Views)