Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CREATEOBJECT() vs ADDOBJECT
Message
De
20/07/1998 20:24:57
 
 
À
20/07/1998 18:47:02
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00119217
Message ID:
00119527
Vues:
21
Not really. If the variable that keeps the reference to the object created with CreateObject() (oCO) is a property of an other object, than the object oCO will be destroyed automatically when its parent is destroyed. So, there is no real difference here compared with an object created with AddObject(). More generic, the object created with CreateObject will be destroyed when its reference is destroyed or changed. That means an object is destroyed when there are no vars or properties that keep reference to that object.

So:

*-- The new object will be destroyed when MyVar goes out of scope, anyway.
MyVar = CreateObject("Label")

MyVar = .f. && Now, the previous object was destroyed.

MyVar = CreateObject("Label")
release MyVar && Now, the previous object was destroyed.

*-- The new object will be destroyed when MyForm will be destroyed, anyway.
MyForm.AProperty = CreateObject("Label")

MyForm.AProperty = CreateObject("Relation") && The Label object was destroyed
MyForm.AProperty = 1 && The Relation object was destroyed

MyForm.AProperty = CreateObject("Custom")
release MyForm && The Custom object was destroyed

It's a little more complicate when 2 vars/properties keep a reference to the same object... :)

Vlad

>In addition to that, an object created with AddObject will go away nicely when the container object goes away. An object created with CreateObject has to be destroyed by your own code. (is that right?)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform