Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help! What am I missing?
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00461092
Message ID:
00461706
Vues:
17
Sorry, John. Serves me right for not testing something.

The problem is once again the COM barrier. When you create an object and pass it to a COM object method, an internal conversion goes on that changes the object into a COM object using an IDispacth interface. Because of this, when you get to the other side and attempt to use VFP commands to copy one array to another, it can't do it. Two ways to go around this limitation:

1. The way you came up with. Copy the array one element at a time.
2. Change the technique a little and only pass an array and have VFP fill that. See code example below:
COM object
function CopyData (tatemp)
=acopy(THIS.lacursor,tatemp)
return
endfunc

program that uses it
local array latemp[1]
=comarray(lo,11)
? lo.CopyData(@latemp)
The COMARRAY call configures VFP to pass arrays as 1-based and by reference. The default is to pass arrays to COM objects as 0-based and by value. We need the reference functionality so the COM object can actually manipulate the array.

Either way works. Performance wise, the ACOPY() may be faster because it is an internal VFP function. However, we are probably only talking about milli- or micro- seconds so I wouldn't worry about that.

Cheers!

>Larry,
>
>Thanks so much for the help.
>
>Your explanation, and suggestions, were exactly what I needed. Vlad, your comments also are appreciated, and support what Larry said.
>
>I did run into one problem with one of your tips, Larry, that I can work around ... but if you see what I'm missing I would appreciate you pointing it out.
>
>You offered two tips - the first worked exactly like you suggested.
>
>The second tip (to pass an object with an array property to a CopyData method) also worked, but not by using ACOPY, as you suggested. I got a "Feature not available". However, I could store the elements of the COM array to the passed-in-object's array by using a FOR loop. I am assuming that Acopy is not available in the COM object for the reasons you already suggested. However, my assumptions are too often wrong... so if you know for a fact that Acopy should work in a COM object, any code snippet you could send that would show me how to use it would be most appreciated.
>
>Thanks again for the help.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform