Return a copy of a vector or Dataset as a one dimensional array of type _VARIANT. GetDataAsOneDimensionalArray is a long name that is not as friendly, GetAs1DArray method is its simple version.
_VARIANT GetDataAsOneDimensionalArray( int lowerBound = 0 )
- [input]The lowest index value in the array (default is 0)
Returns a one dimensional array of type _VARIANT containg a copy of the data in a vector or Dataset.
// Declare a vector and fill with some data
for( int ii=0; ii < 360; ii++ )
vec[ii] = sin(2* ii * PI / 360.0);
// Get the data from the vector into an 1-dimensional _VARIANT object
varYData = vec.GetDataAsOneDimensionalArray();
//Output the _VARIANT size
out_int("size is ", varYData.GetSize());
When 1-dimensional objects such a vector or a Dataset is assigned to a COM object of type _VARIANT, a 2-dimensional array is created where the second dimension is set to 1. This is because applications such as Excel expect a 2-dimensional object such as when when assigning a _VARIANT to a range object.
However, some COM objects require 1-dimensional arrays of type _VARIANT. This function returns a 1-dimensional array from a vector or a Dataset.
_VARIANT is a universal type that exists in COM to hold various types of data. It is used to get the values of properties of COM objects. It can represent individual values of int, double, etc., as well as arrays and other composite types.
Header to Include