08-05-2021 04:58 AM
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
08-05-2021 09:25 AM
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:
Hope this helps,
08-09-2021 03:16 AM
Thanks a lot jigg for the answer, I will test it.
08-15-2021 07:02 AM
I think Sam's answer should be marked as a solution. I'm just saying 😉
07-08-2023 11:08 PM
It doesn't work. eg:
Locals.LED_enum_as_index.SetValNumber("", 0x18, Locals.LED_index)
returns just a number.
It doesn't select the enumerated value.
This would work.
It's extremely verbose and long -- you can create an array with one enum value in each like this:
Locals.array[0] = [0-9.99C] (0)
Locals.array[1] = [10-19.99C] (1)
.
.
Locals.array[6] = [60-69.99C] (6)
But there must be a more clever way.