LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Array to Variant

Hello,
 
Below you will see to examples of code
 
{
 VARIANT XV,
 double x[2][4];
 
 CA_VariantSet2DArray (&XV, CAVT_DOUBLE, 2, 4, x);  
 
}
 
{
 VARIANT XV,
 double *x[2];
 
 x[0] = malloc (4 * sizeof (double));
 x[1] = malloc (4 * sizeof (double)); 
 CA_VariantSet2DArray (&XV, CAVT_DOUBLE, 2, 4, x);  
 
}
 
The first one is working the second not. Why?
How can I used varable array sizes with VARIANTS?
 
Thank you
Bertrand
0 Kudos
Message 1 of 4
(3,222 Views)
I have had the same problem some time ago ang got an answer that I couldn't find at the moment: basically, the reason is that the system does not guarantees that dynamically created arrays like yours are contiguous, so the translation to VARIANT cannot be completed. With static arrays like your first example this is always guaranted. I will try to locate the discussion to link it for you.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(3,211 Views)

Roberto, was this the link you had in mind?

JR

0 Kudos
Message 3 of 4
(3,205 Views)
Yes, JR, thanks for adding the link! Smiley Happy
 
I was so involved in that problem that I thought to have posted this question personally! Thats why I couldn't find it in my recent posts: getting old too rapidly? Smiley Very Happy


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 4
(3,191 Views)