LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arithmetic and casting enums

I'm trying to do some arithmetic operations on enums using the compound arithmetic vi, and using the result as a selector for a case structure. The problem is that the compound arithmetic vi changes the data type to long (from U16). I tried using the type cast vi with the type input wired to an enum constant to convert the result back to the enum data type, but I keep getting a wrong result. I've checked the arithmetic and its correct the problem is casting the result back to the enum type.
0 Kudos
Message 1 of 6
(2,781 Views)
It is possible to convert enum-type to string and use it as case structure selector.
See attached example.
Message 2 of 6
(2,781 Views)
Thanks for your answer, but the vi you sent me does'nt work right, the case structure always goes to the case indicated in AbortEx4 and not to the result of the compound arithmetic (which is the same problem I encountered).
0 Kudos
Message 3 of 6
(2,781 Views)
Connect output of arithmetic compound to input1 of Format To String in place of enum constant.
Hope that will work.
0 Kudos
Message 4 of 6
(2,781 Views)
The old typecasting pitfall...

You attempt to typecast a I32 to an enum(U16). The function uses only the 2 upper bytes of the result which are always 0. Either put a conversion to U16 before the typecast node or change the type of the enum to U32.


LabVIEW, C'est LabVIEW

Message 5 of 6
(2,781 Views)
Thanks a million
0 Kudos
Message 6 of 6
(2,781 Views)