Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can an object know of it's existence?
Message
From
03/12/2003 14:03:45
 
 
To
03/12/2003 13:38:59
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00855003
Message ID:
00855565
Views:
26
Hi Stefan,

>I was merely trying to point out the flawed logic behind your question, and that the question you did ask was not the one that you wanted answered. ;-) Specifically:
>
>ox = CREATEOBJECT("myclass")
>I need the "ox" in the INIT.

Well, you got me there. :-) I admit my question could have been worded better. Forgive me for my lack of experience in this area.

>From what you told us it is apparent that you need globally reachable names for the object instances (for the callbacks) but customers of your class are more likely to use local references - local variables, object properties, whatever. So the simple solution is to create unique global names for callback purposes which the clients of the class don't need to know unless they want to; "g_JimsTimer" + SYS(2015) should do nicely. However, the clients need to tell the object when it is no longer needed so that the object can unregister the callback and clean up the global reference.
>
>If you want a global callback and automatic cleanup when the client's reference goes away then it gets a little tricky, because normally the object will not be destroyed while the global reference is still there. It is possible - you just need an additional layer of indirection - but it is not exactly straightforward.
>
>As regards the article with Fernando's solution - I just browsed the thread again but couldn't find it either. I guess I must have confused some other thread with this one, but I am fairly sure that it was Fernando's example that I liked most. *g* Be that as it may, the basic idea of the solution was similar to this:
>
>Snipped a bit
>
>which allows clients to specify a global name if they so choose but does not require them to do so.

Thanks for the excellent examples. Now I better understand what you originally were trying to tell me. Now I'll see if I can put it to use.
Previous
Reply
Map
View

Click here to load this message in the networking platform