General information
Category:
Coding, syntax & commands
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
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only