07-19-2018 03:59 PM
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
Solved! Go to Solution.
07-19-2018 04:19 PM
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
07-19-2018 04:53 PM
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.
07-19-2018 05:13 PM
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
07-19-2018 05:17 PM
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.
07-20-2018 06:17 PM - edited 07-20-2018 06:20 PM
So, I would do this to replace the #19 FALSE with a TRUE
07-20-2018 08:32 PM - edited 07-21-2018 03:47 PM
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.
07-20-2018 11:21 PM
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.
07-20-2018 11:22 PM
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.
07-20-2018 11:23 PM
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.