NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically change Enum values

I have an Enum , Enums.State with many states likeCommand1,..2, 3 etc

I want to programatically change these values with a For loop.

How to send enum variables values from an Integer ? 

 

Thanks Akshay

0 Kudos
Message 1 of 4
(327 Views)

Not sure if you've read through the help on this but assignment can only be done with enums of the same type: https://zone.ni.com/reference/en-XX/help/370052AA-01/tsfundamentals/infotopics/enumsastsexpressions/

 

However, you can use the SetValNumber and the coerce to enum flag:

Locals.MyEnum.SetValNumber("", 0x18, 1) where MyEnum is the enum and 1 is the numeric selection I want to make it. n 0x18 is the flag for coerce to enum:

  • PropOption_CoerceToEnum–(Value: 0x18) Use this option for implicit conversion when setting an enumeration value with a string or number. You can use this option with the PropertyObject.SetValNumber and PropertyObject.SetValString methods. TestStand ignores this flag when you specify PropOption_InsertIfMissing and the property does not exist.

 

Hope this helps,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 4
(312 Views)

Thanks a lot jigg for the answer, I will test it.

0 Kudos
Message 3 of 4
(292 Views)

I think Sam's answer should be marked as a solution. I'm just saying 😉

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 4 of 4
(268 Views)