LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Odd behavior of "Variant to Data"

Hello everyone,

I ran into an unexpected result when using "Variant to Data" vi. As I understand, the Variant to Data vi will output the default value of data type wired in "type" terminal when an error occurred before this vi. With this understanding, I think the output result of following vi is an array with element "100" and "0".

OddBehaviorOfVariantToData.png

However, I got an unexpected array with element "100" and "100" (LabVIEW 2014). It seems like that the "Variant to Data" vi output the result of previous successful execution when an error exists in "error in" terminal.

ResultScreenShot.PNG

  Is there something I misunderstand about "Variant to Data" vi??

 

 Thank for any help you can provide.

0 Kudos
Message 1 of 7
(2,374 Views)

 

variant.png 

Tried the same in 2015 i am getting 100,0

FP.PNG

 

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 7
(2,364 Views)

Found the same issue when using Case.

Without case structure it gives proper result.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 3 of 7
(2,356 Views)

I believe you slightly misunderstood the Help message.  It says "

If variant could not be converted to the data type specified, this data returns the default value for the data type.

It does not say this happens if there is an Error on Error In.  Many (most?) LabVIEW functions will, indeed, not run and return Default Values on Error In, but Variant to Data is only doing "data re-interpretation", for example re-interpreting a 32-bit bit pattern, read in as a U32, as a Sgl (which also takes 32 bits).  Since no "computation" is being done, the LabVIEW Development Team probably concluded that this wouldn't be a problem.  The only time there would be a problem is if you tried to convert it to a bit-incompatible data type, like a U32 to a 64-bit Dbl.

 

Bob Schor

Message 4 of 7
(2,353 Views)

Hello Bob,

 

Same Functionality when addressing in different ways (with and without case structure gives different output)

 

 

 

 

variant1.pngFP.PNG

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 5 of 7
(2,350 Views)

Reproduced in 2016, but not in 2018.

 

I want to say that this issue was discussed in a private board.  The issue there was specific to classes, but it was acting similar to this.  I think the issue was fixed in either 2017 SP1 or 2018.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 7
(2,343 Views)

Issue Reproduced in LV2017

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 7 of 7
(2,328 Views)