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.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

GetValString("", PropOption_CoerceFromEnum) is not working on values retuned from LabVIEW

Solved!
Go to solution

I checked TestStand 2019 (32-bit)\Examples\Fundamentals\Using TestStand Enumerations\LabVIEW\Using TestStand Enumerations.seq example.

 

I tried to get enum string and value in watch window using Locals.Color.GetValString("", PropOption_CoerceFromEnum) and Locals.Color.GetValNumber("", PropOption_CoerceFromEnum)

 

Only GetValNumber works. Why I can't get enum string this way? According to the documentation I should be able to accomplish this with flag PropOption_CoerceFromEnum (Use this option for implicit conversion when using an enumeration value as a string or number. You can use this option with the PropertyObject.GetValNumber and PropertyObject.GetValString methods).

 

EnumsIssue.png

 

To have GetValString working I need to manualy select enum value in variables pane (so the curly brackets change into square brackets).

 

EDIT:

I was able to get enum string with Locals.MyEnum.Enumerators.GetPropertyObjectByOffset(Locals.MyEnum.GetValNumber("", PropOption_CoerceFromEnum), PropOption_NoOptions).GetValString("", PropOption_CoerceFromEnum) but this will work only if MyEnum values are Enumerators offset indices.

Michał Bieńkowski
CLA, CTA

Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
0 Kudos
Message 1 of 5
(1,505 Views)

My understanding is that the CoerceFromEnum option works for only TS Enums and not for LV Enums, I believe the reason is simple as TS has access to only TS ENUM definitions to translate the ENUMS to String but not the LV side.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 5
(1,453 Views)

I tried this with other adapters and the problem appears with all of them (so I should correct this thread title).

 

Anyway, we are not talking about LabVIEW enums. You can see on the screen that the value from the adapter is properly converted to the TestStand variable. What's more GetValNumber works with this propo as expected.

Michał Bieńkowski
CLA, CTA

Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
0 Kudos
Message 3 of 5
(1,447 Views)
Solution
Accepted by topic author bienieck

Simply use 

Locals.Color.GetValString("",PropOption_Coerce)

or

Str(Locals.Color)

 

 

Message 4 of 5
(1,402 Views)

enum.png

It works. So, why does PropOption_Coerce (I think it is actually PropOption_CoerceFromNumber OR PropOption_CoerceToString) work and PropOption_CoerceFromEnum not? This is strange.

Michał Bieńkowski
CLA, CTA

Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
0 Kudos
Message 5 of 5
(1,394 Views)