Information générale
Catégorie:
Codage, syntaxe et commandes
Jacky:
Are you creating forms with DO FORM or CREATEOBJECT? Checking whethee an object exists is a little tricky if you create forms with CREATEOBJECT and remove objects at runtime with RemoveObject.
Removing an object from a form iunstantitated with CREATEOBJECT does not remove the object from the members collection (it does remove it from the controls collection however). For example, construct a form class named myForm that has one textbox named myTextBox. From the Command Window:
loForm = CreateObject('myForm')
loForm.Show()
loForm.RemoveObject('myTextBox')
? PemStatus(loForm, 'myTextbox', 3) <-- this returns 'Object'
? loForm.ControlCount <-- this returns 0
? Vartype(loForm.myTextbox) <-- this returns 'O'
? Type('loForm.myTextbox') <-- this returns 'O'
The safest way to determine if an object exists is to verify the value returned by TYPE("THISFORM.MyObject.Name"). If it returns "C", the MyObject property contains a valid reference to an object (the object was not removed). If it returns "U", either the MyObject object no longer exists or the MyObject property no longer contains a valid reference (the object was removed).
Daniel
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement