Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Working with Safe Arrays?
Message
From
05/08/2004 13:01:23
Gary Foster
Pointsource Consulting LLC
Chanhassen, Minnesota, United States
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00930360
Message ID:
00931082
Views:
27
Sergey,

BTW, just to continue a thread almost no one in the VFP community cares about<g>, CreateBinary() will create a string that can be passed as a safearray of VT_UI1 as in cStr = CreateBinary('123456578'), but cStr cannot be passed BY_REF even using ComArray(oComObject,10). Only by first creating an array as byte and filling it can we pass by reference as some COM servers require for passing data back and forth.

Maybe this obscure info will save someone some grief sometime.

Disclaimer: Since I didn't write the COM data thingy, I don't know exactly what it's doing under the covers, but it seems to work, e.g., passing a date returns VT_DATE, 1234 returns VT_I4, etc.

ComArray(oComObj,10)
DIMENSION MyArray[5] as BYTE
MyArray[1] = '1'
MyArray[2] = '2'
MyArray[3] = '3'
MyArray[4] = '4'
MyArray[5] = '5'
MyStr = CreateBinary('12345')

oComObj(MyStr) && VT_ARRAY|VT_UI1
oComObj(@MyStr) && VT_ARRAY|VT_UI1
oComObj(MyArray) && VT_ARRAY|VT_UI1- still seen as array even w/o the @
oComObj(@MyArray) && VT_ARRAY|VT_UI1|BY_REF

Gary


>Hi Gary,
>
>It's interesting info. Thank you.
>>>A fellow I worked with a few years ago wrote a C++ COM object to test what was sent to it when we were fruitlessly trying to pass safearray's to COM servers from VFP6. Starting with VFP8, the following code works:
>>
>>COMServer = CreateObject('something.class')
>>DIMENSION MyArray as BYTE
>>MyArray = 1 && Works without this line too
>>COMARRAY(COMServer,10) && Pass by ref
>>COMServer.Method(@MyArray)
>>
>>The test object shows VT_ARRAY of VT_UI1 VT_BYREF
>>
>>If I leave off the "as BYTE", I get VT_ARRAY of VT_VARIANT VT_BYREF
>>
>>If I use:
>>DIMENSION MyArray as STRING
>>MyArray = 'A'
>>I get VT_ARRAY of VT_BSTR VT_BYREF
>>
>>The "as" clause seems to make a difference.
>>
>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform