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:
00461341
Vues:
13
John,
You posted this awhile back and it intrigued me but I never got a chance to check on it until now.

The property are still an array property but it is being masked by the COM barrier. To prove it is an array, try putting o.AnArray[2,1] in the Locals window and a value should be returned.

Attempting to view the array directly or use VFP array functions against it outside of the COM wrapper will fail.

Some tips:
1. Since Alen() won't work, add a property to your class (e.g. ArrLength) and a corresponding _Access method. In the _Access method, simply issue a return alen(THIS.AnArray). Then you can use it in your for xx = 1 to o.ArrLength statements.
2. If you want the array in a VFP friendly way, add a CopyData method. Pass in an object with an array property and use Acopy() to copy the object's array values to the objects. You won't have to return anything because you are passing the object parameter by reference.

HTH.

>I am unable to get an object created as a com object to support an array.
>What am I doing wrong - or more likely, what is it I don't understand?
>
>Sample 1: Save this code to a prg, add to a project, and build the project as a DLL. Call the dll, e.g., "AComDll"
>
>**** CODE FOR SAMPLE 1 PRG ******
>DEFINE CLASS AnObject AS custom OLEPUBLIC
>DIMENSION AnArray[3,1]
>PROCEDURE AMethod
>store 'John' to this.AnArray
>ENDPROC
>ENDDEFINE
>**** END OF CODE ******
>
>Now run these two lines from the command window to create an instance of the object, and to fire the method:
>
>o = createobject('AComDll.AnObject')
>o.AMethod()
>
>Use debug's "locals" window, and note that o.AnArray is NOT an array.
>
>Sample 2: Save this code to a prg and execute the PRG
>
>**** CODE FOR SAMPLE 2 PRG ******
>clea all
>public o
>o = createobject('AnObject')
>= o.AMethod()
>
>DEFINE CLASS AnObject AS custom
>DIMENSION AnArray[3,1]
>PROCEDURE AMethod
>store 'John' to this.AnArray
>ENDPROC
>ENDDEFINE
>**** END OF CODE ******
>
>Now use debug's "locals" window, and you will see that o.AnArray IS STILL an array.
>
>Any suggestions will be most appreciated!
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