I'm working with a COM module that is returning a 2D array as a
VARIANT BYREF. The 2D array is 30x8 (with each entry being 1 byte)
When the data is returned I'm getting a buffer of length 30. This
tells me that win32com only sees 1D of the array (documentation states
that the buffer is expected for variants-byref with entries of 1
byte). Any ideas on why win32com doesn't see that there is really an
array of arrays?

The author of the code tests with VB so it seems to be working there,
but not with Python. Here's a rough code snippet from the com module
on how it is building the variant that needs to be returned.

long lDimension[2] = {0,0};
SAFEARRAY *dataBuffer = variantReturn.parray;

psaDataBuffer->rgsabound[0].cElements // this is programmed to 8 somewhere
psaDataBuffer->rgsabound[1].cElements // this is programmed to 30 somewhere

// For each field of the entry
for(int outerindex=0; outerindex<30; outerindex++){
    lDimension[0] = outerindex;
    for(int innerindex=0; innerindex<8; innerindex++){
        lDimension[1] = innerindex
        SafeArrayPutElement(dataBuffer,lDimension,
&data[outerindex][innerindex])
        }
}
// variantReturn is the actuall return that I'm trying to get.

Any ideas?

Thanks,
Kevin
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to