LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I type cast an integer to an enumeration type.

When I feed an integer to the type cast icon, I do not get the corresponding enumerated type given to the type input. What am I doing wrong?
0 Kudos
Message 1 of 6
(3,622 Views)
"wwbrown" schrieb im Newsbeitrag
news:506500000008000000AF300000-1004225886000@exchange.ni.com...
> When I feed an integer to the type cast icon, I do not get the
> corresponding enumerated type given to the type input. What am I
> doing wrong?

you have to use the type conversion function located inside the
advanced->data manipulation palette of the block diagram. Wire your integer
from the left side and enum type from top. Now you can connect the right
output with your needed indicator or function.

Henrik
0 Kudos
Message 2 of 6
(3,620 Views)
Thanks Henrik. I was using the type cast but the real problem was a "gotcha". The input integer MUST BE THE SAME SIZE as the enum type (usually U16), for the conversion to work. I was using I32 with a U16 enum type and always getting a zero for the conversion.
W. Brown
0 Kudos
Message 4 of 6
(3,620 Views)
Right-Click on the enumerated which is wired to the "type" input and select "Representation>>U32".


Michael Aivaliotis
VI Shots LLC
Message 3 of 6
(3,620 Views)
Bingo! You got it. The input integer has to be the same size as the enum type. Thanks. W. Brown
0 Kudos
Message 5 of 6
(3,620 Views)
Alternatively, rather than using a type conversion function to convert the representation of whatever is wired to the "type" input, you can convert the representation of the input X to be the same representation as the type (which for an enum is one of U32, U16, or U8).

See attachment.
0 Kudos
Message 6 of 6
(3,567 Views)