08-23-2012 05:31 AM
It is possible to convert any data type to a variant, and then back again. When doing so, are there any data types that will lose information during the conversion process? If so, why?
Solved! Go to Solution.
08-23-2012 10:10 AM
Yes, you can convert any type to a variant and back. There is a VI called "Variant to Data" that will take a type as an input. This is sued to convert the variant back to the correct data. The receiving side of the variant must know what data type to expect. It can't derive it from the variant. However, you can use a generic data cluster that consists of an identifer and a variant. Then you can have different data types that the receiving side can process. It is a two step process. One to conver the variant to the general type (cluster of type and variant data). The second would be a case statement which uses type to then covert the inner variant to the specified type. This approach is used for generic messaging systems. The higher levels of the code will know what to do with the data. The lower levels are just passing generic data around.
I am not aware of any information that gets lost when converting data to and from a variant. I certainly haven't encountered any problems using them.