LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change Variant type name programatically

Solved!
Go to solution

Hi,

 

I use Variants to communicate between Queue State Machines similar to the Queued Message Handler Template. These Variants have type names which I use to distinguish between different values. I don't know how I can change them programmatically. At the moment I use String constants with static labels. The problem arises if I get the String from a VI, then I can't change the name.

grafik.png

 

Steffen_Zienert_0-1634053571773.png

Here a more elaborate example which is more similar to what I am doing.

Steffen_Zienert_3-1634055137717.png

 

 

0 Kudos
Message 1 of 5
(167 Views)

Type cast into the same type but label the constant you feed into the type terminal (also a quick and dirty trick for named probes which is how I found out about it):

 

Spoiler
FireFistRedhawk_0-1634059495937.png

 

 

 

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

Message 2 of 5
(156 Views)
Solution
Accepted by topic author Steffen_Zienert

Using Coerce to Type is safer, as you know it's not going to reinterpret the memory.

Message 3 of 5
(121 Views)

@pauldavey wrote:

Using Coerce to Type is safer, as you know it's not going to reinterpret the memory.


One day I'll get to move on from 2017 😭

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 4 of 5
(90 Views)

@FireFist-Redhawk wrote:

@pauldavey wrote:

Using Coerce to Type is safer, as you know it's not going to reinterpret the memory.


One day I'll get to move on from 2017 😭


"Coerce to Type" is available in 2017 (and earlier). It's just not visible in the palette: https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Officially-Support-quot-Coerce-to-Type-quot/idi-p/121...

Certified LabVIEW Developer
0 Kudos
Message 5 of 5
(50 Views)