Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Vaild object exist or not .
Message
From
14/03/2001 12:04:28
 
 
To
14/03/2001 01:18:52
Jacky Yuen
Myth Group Computer Technology
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00484744
Message ID:
00484930
Views:
15
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
Map
View

Click here to load this message in the networking platform