Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Question on releasing object and setting to .NULL.
Message
 
 
To
14/05/2009 17:37:37
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01399978
Message ID:
01399994
Views:
61
Mark,

I use a UDF IsObject() to perform the test:
lparameter roObject

return( ( type( "m.roObject" ) == 'O' ) and ( ! isnull( m.roObject ) ) )
Setting an object reference to .null. has always felt like the cleaner way to clear out the pointer to an object. Sometimes you need to know if it ever was assigned to an object. Assigning .f. and causing it to change datatypes isn't quite as good IMO.

>Standard practice seems to be, to set an object's property to .NULL. after releasing an object tied to a property. For example:
>
>o=CREATEOBJECT("empty")
>ADDPROPERTY(o, "o1", CREATEOBJECT("form"))
>o.o1.release()
>o.o1=.null.
>? TYPE("o.o1")  && still shows "O"
>
>
>It seems it would be better to set the property to .F. instead, after releasing it. That way, anything that tests for TYPE("o.o1") = "O" would not be fooled. Setting the property to .NULL. still leaves the type as "O" (object). Whereas, setting the property to .F. changes the type to "L". Is there a good reason for using .null.? Which requires an additional test using ISNULL(). I often check using TYPE("..") = "O" because the property may not have been created and/or assigned. Thanks for any insight into reasons for using the .NULL. assignment.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform