Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global function REALARR()
- sequence seq
- atom psa
- atom var
- seq = { "cat","cow","wolverine" }
- psa = create_safearray( seq, VT_BSTR )
- make_variant( var, VT_ARRAY + VT_BSTR, psa )
- return var
- end function
- [
- helpstring("get an array of strings"),
- entry("REALARR")
- ]
- void __stdcall REALARR( [out,retval] VARIANT* res );
- ...
- Dim v() as String
- V = REALARR()
- ...
- sequence s, bstrs
- s = {"A", "B"}
- bstrs = {}
- for i = 1 to length(s) do
- bstrs &= alloc_bstr( s[i] )
- end for
- atom array
- array = create_safearray( bstrs, VT_BSTR )
- ...
- destroy_safearray( array )
- 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
- var = allocate( 16 )
Add Comment
Please, Sign In to add comment