>>>I can't quite grok the help, and in actual practice I have only used AddObject (as well as CreateObject()). Is there any difference in behavior between the two functions - NewObject() and AddObject() - apart from the slightly different syntax (for instance, NewObject allows specifying a class library)?
>>>
>>>TIA,
>>>
>>>Hilmar.
>>
>>NewObject() is the equivalent of CreateObject() except that CreateObject() requires that you have either the PROCEDURE file or CLASSLIB set. Addobject simply creates a property to which you can assign the new object
>>SET PROCEDURE TO myProc
>>this.addproperty("newProp",CREATEOBJECT("myclass_in_myproc"))
>>
>>SET PROCEDURE TO
>>this.addproperty("secondprop",NEWOBJECT("myclass_in_myproc","myproc.prg"))
>
>Sorry, but aren't you confusing AddObject() with AddProperty()?
There is a substantial difference. Object added as a property is just a property which is an object pointer, but that object isn't a member (i.e. its .parent is null, it's not among oObject.objects). OTOH, oObject.addobject(...) and oObject.NewObject(.....) will create a member object. For the outside world this new object behaves the same (the syntax oObject.newlyaddedobject.property will be the same), but newlyaddedobject.parent=oObject, and newlyaddedobject is a member of oObject.objects collection.