LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to cast to a type dynamically?

I have an array of byte (U8) which I want to cast to multiple different clusters whose references i have.

 

Is that possible, and if it is how?

0 Kudos
Message 1 of 4
(2,411 Views)
Yes this is possible, but it might be a little difficult depending upon how flexible you need to be. How many different cluster types are you dealing with? Is it acceptable to hard code a type cast for each depending on type in a case structure, or do you need to this to be completely dynamic?
Jarrod S.
National Instruments
0 Kudos
Message 2 of 4
(2,405 Views)

I have to handle about 25 differrent clusters.

To use a case structure with 25 cases is what I want to avoid.

0 Kudos
Message 3 of 4
(2,365 Views)
There are some really nice OpenG (open source) tools that can help you get started setting data in arbitrary clusters. You can get them using the VI Package Manager from JKI Software. The oglib_lvdata library has functions for dealing with arbitrary clusters with functions to get the names and data types of cluster elements, or to create clusters from scratch using variant data. These should be the building blocks you'll need to marshal an array of bytes into a specific cluster type.
Jarrod S.
National Instruments
0 Kudos
Message 4 of 4
(2,334 Views)