Re: EuCOM and VARIANT arrays of BSTR
- Posted by axtens Oct 16, 2008
- 1087 views
raseu said...
the following will work for array of strings to a standard 'C' shared library, i expect the principles would be similar for OLE/Variant string arrays.
Thanks for that. The approach certainly bears some more thinking about.
I've just been fiddling with my code, comparing it to some old Fortran code, partly generated by Compaq Visual Fortran's COM wizard and thought I was getting a bit closer. Sadly, nothing yet, but reproduced below just in case anyone sees something obvious that I've missed.
global function REALARR() atom psa atom var atom bounds_ptr atom dim atom bstr object void dim = 1 bounds_ptr = allocate( 8 * dim ) -- now figure out which part is Extent and which is LBound poke4( bounds_ptr, { 3, 0 } ) -- assuming Extent and LBound in that order psa = c_func( SafeArrayCreate, { VT_BSTR, 1, bounds_ptr } ) bstr = alloc_bstr( "cat" ) poke4( bounds_ptr, 0 ) void = c_func( SafeArrayPutElement, {psa, bounds_ptr, bstr}) free_bstr( bstr ) bstr = alloc_bstr( "cow" ) poke4( bounds_ptr, 1 ) void = c_func( SafeArrayPutElement, {psa, bounds_ptr, bstr}) free_bstr( bstr ) bstr = alloc_bstr( "wolverine" ) poke4( bounds_ptr, 2 ) void = c_func( SafeArrayPutElement, {psa, bounds_ptr, bstr}) free_bstr( bstr ) make_variant( var, VT_ARRAY + VT_BSTR, psa ) return var end function
Kind regards,
Bruce.