03-06-2024 08:12 AM - edited 03-06-2024 08:14 AM
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!
03-06-2024 08:51 AM - edited 03-06-2024 08:55 AM
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.
03-06-2024 08:53 AM - edited 03-06-2024 08:53 AM
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…
03-06-2024 09:38 AM - edited 03-06-2024 09:57 AM
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.
Some recommendations:
03-06-2024 10:12 AM
You need to convert the variant part back in a separate step, presumably based on the test type.
03-07-2024 05:31 AM
A simple proof that the value of a variant in a cluster in an array isn't shown:
03-07-2024 06:13 AM
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.
03-12-2024 03:12 AM
Hi all,
Thank you very much for all your answers! I found a solution and your advice was very useful!
Thanks again!