LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array of cluster with variant converted into variant looses variant value

Hello,

 

I'm encountering an issue with a variant conversion: in my application, I have to deal with an array of cluster. This cluster is formed of:

- one string (test case name)

- one boolean (test case PASS/FAIL)

- one variant (test result)

 

When I look at the values stored into the array, all is fine and I see the variant values. However, as soon as I convert this array into a variant, all variant located within the clusters are lost.

 

Do you know why?

 

See below the data from array and data after conversion into variant and I also attached a test VI.

 

Thank you very much for your support!

 

Gub156_0-1709734141962.png

Gub156_1-1709734151396.png

 

0 Kudos
Message 1 of 8
(804 Views)

That's just the behavior of the Variant control. The data is not lost, it's just not shown. If you use "Variant to Data" you can convert that variant back to the normal array and the variant data will still be there.

 

If you right click on the Variant control and select "Show Type" you can see the Variant type is still inside of there. You can also use the "Flatten to XML" method to see the Variant in the Variant instead of using a Variant Control if this is just for debug purposes. 

0 Kudos
Message 2 of 8
(781 Views)

Hi Gub,

 


@Gub156 wrote:

However, as soon as I convert this array into a variant, all variant located within the clusters are lost.


Why do you think so?

Before and after variant show the same…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 8
(777 Views)

Nothing is lost. The data display of a variant just has some limitations for good reason. There is no point of displaying pages of useless information in the variant indicator. I would even right-click and uncheck "show data". If you want to see more information, you could check "show type" in addition, as shown below.

 

altenbach_0-1709740616039.png

 

 

 

altenbach_0-1709740402819.png

 

 

Some recommendations:

  • I am pretty sure you want to initialize your shift register to prevent the "column name" array from growing forever with successive runs. A concatenating tunnel would be more reasonable:
  • It is highly recommended to expand arrays to show the first unused element to make sure nothing is hidden. For larger arrays, show the scrollbar.
  • When attaching code containing typedefs, you also should attach the typedef.
  • Defining all cluster and use "By name" is much more self-documenting.
  • It help to show the names of cluster elements for types.
  • etc.
0 Kudos
Message 4 of 8
(739 Views)

You need to convert the variant part back in a separate step, presumably based on the test type.

Yamaeda_0-1709741572358.png

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 8
(720 Views)

A simple proof that the value of a variant in a cluster in an array isn't shown:

wiebeCARYA_0-1709811083595.png

 

Message 6 of 8
(683 Views)

wiebe@CARYA wrote:

A simple proof that the value of a variant in a cluster in an array isn't shown:


But as shown, the information is still there and i'd say you're not supposed to use the variant indicator to show such information. It'd be neat if it did write the data recursively. If you really want to use dynamic clusters and show them this way i'd go with JSON.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 7 of 8
(676 Views)

Hi all,


Thank you very much for all your answers! I found a solution and your advice was very useful!


Thanks again!

0 Kudos
Message 8 of 8
(613 Views)