This is probably basic, but I can't figure it out.
I have made a property in IDL/C++ which takes a VARIANT as input
[id(310), helpstring("Data")] VARIANT Data;
If I assign data from a VBScript like this, it works:
arrayout = Array(1.23, 2.34, 12.5)
output.Data = arrayout
But if I do the more common like this, It does not.This is probably basic, but I can't
Dim
arrayout()ReDim arrayout(2)
...Put data in...
output.Data = arrayout
I have read that Array() makes a VARAINT type, which makes sense why it works, but how can I get the ReDim etc. without using Array() function to work
-cpede

Difference between Array() and ReDim
eldiener
Ok I figured it out.
When doing Dim and Redim the variant type is passed by reference, and I have to check for the VT_BYREF and use the ->pparray union variable.
When using the Array() function it is not passed by reference, and I use the ->parray union variable.
-cpede
Prabu.
Hi cpede,
Thats a curious problem. Had a read on the differences between using the Array function and the using the Dim/ReDim.
In the help for the Array() function it says...
a Variant containing an array is conceptually different from an array whose elements are of type Variant, the array elements are accessed in the same way.
It looks like Array creates a variant containing an array, while Dim/ReDim creates an array whose elements are variants. You don't notice the difference because they are accessed the same way.
It makes sense why the Array works because your C++ code is expecting a variant, not an array.
Try this instead, it might work but I'm not sure...
Dim arrayout()
ReDim arrayout(2)
...Put data in...
Dim arryout2 as Variant
arryout2 = arrayout
output.Data = arryout2