Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pass an array to a VFP COM Object
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00191796
Message ID:
00193072
Views:
16
>>I've run into all sorts of problems where I've needed to pass an array of char with embedded nulls to a VFP COM object; if I stick an array of char into a property, I don't run into the same problems I have when passing the array of char as a parameter. I don't know why I have the problem, but it's bitten me a couple of times in an object that I use for one of my routing servers. If I could reliably pass an array of char to VFP by reference and get it back resized, I'd be a much happier camper - what I do now is pass in the list of known intermedite points, and then read a property on return to get the adjusted route.
>
>I think the problem has more to do with how Variant strings are handled
>by VFP. You can't use VB/C++ type ByteArrays with VFP over COM- only true SafeArrays that have variant BSTR values. If you use those they
>should work fine with VFP.
>
>Binary data in strings is always a problem <s> - but VFP handles this data
>fine usually - it's most string classes (especially the COM _bstr_t and
>_variant_t classes) that don't handle binary strings properly. Make sure
>your data actually contains what you think it does before it goes to
>VFP.
>

I know about at least some of the problems with _bstr_t; we had to change some classes we derived from it to eliminate some bleed problems a few months back in a control we wrote for a client. I don't find that access to altered data sets via a collection is particularly objectionable, at least for the application we're working on at the moment, since some of the routing controls are being accessed inside Word and Excel with VBA, and it's easy to get VBA to spin through collections. I'd be much happier with VFP if there were a mechanism to implement a collection interface in a VFP COM object; it'd solve a number of problems where we resort to passing arrays now, or where we've just given up on VFP as the language for implementing some business objects.

>Finally, try different combinations of the COMARRAY() function to get the
>passing by value/reference and 0 or 1 based nature of the array right for
>the object.
>
>>Yes, I am aware that an assignment is a method call that actually invokes the necessary marshalling needed to pass stuff across a process (or even at times across a thread) boundary. Maybe I'm doing something dumb.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform