Hi Anthony,

When you instantiate a COM-object, the interface is read from a Isomething
interface definition. This definition is generated at compile time of the
COM object. Now VFP is not a strong typed language where your stuff property
is not typed as a collection. This means that the property is defined for
your interface as a variant type. This will make VFP query the instance of
the COM object-property for the actual type of the property. The Collection
interface however is not defined, so it just knows it's an object. The
properties or methods of that object are unknown.
To solve your problem: try to type your properties using the COMATTRIB flags
in the class definitions.

Sietse

-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Anthony L. Testi
Verzonden: donderdag 19 april 2007 17:35
Aan: [EMAIL PROTECTED]
Onderwerp: Collections and DLLs needing some help please

I am using VFP 9.0 and am trying to return a collection from a DLL with no
luck.  Is there some trick that I am missing?

For example I have created a DLL ( Named Junk2 ) that has one class (Junk)
in one prg (test.prg) Code follows:

DEFINE CLASS Junk as Custom OLEPUBLIC
Stuff = null
Foobar = null
        
FUNCTION Init()
  this.Stuff = NEWOBJECT( [Collection])
  This.Stuff.Add( [This is a test this is only a test] )
                
  This.FooBar = [This is foobar]
                
ENDFUNC && Init
        
ENDDEFINE

As can be seen it has two class properties: 
  -Stuff ( which in the init is made into a collection )
  -FooBar ( Which in the init is made into a string )

I then wrote the following testing code:

SET STEP ON 
X = CREATEOBJECT( [Junk2.JUNK] )  &&-- OPtion one does not work
*X = NEWOBJECT( [Junk], [Test.prg] ) &&-- Option 2 works
Z = X.FooBar
Z = X.Stuff
z = 1

When I do the "X = NEWOBJECT( [Junk], [Test.prg] )" option
I can see in the debugger that X.Stuff is a collection

When I run the code "X = CREATEOBJECT( [Junk2.JUNK] )" option
X.Stuff is an object but not a collection.

In both options x.foobar is a string as I expect.

What am I missing?


Anthony L. Testi


[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL 
PROTECTED]@sw-software.nl
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to