Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Referencing Objects...IDEAS?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00167801
Message ID:
00167806
Vues:
19
try storing the refs in an array that resizes to the number of open forms each time you create or close a form - this, ideally, should be managed through an global application object where the array exists as a property ...

>Hey all,
>
>I have been struggling with this for some time. We all know how VFP references objects. If you declare a local variable and point it to an object, as soon as the module is done, the variable goes out of scope and the object disappears.
>
>Great. Now, let's say I want to create an object all on its own, and have it remain in memory after the function or procedure is gone (whether or not it can be referenced or not is not important to me, as the object takes care of itself...it is a form). The obvious way to do this is to create a PUBLIC variable and point that to the object so it never goes out scope. Great. But then when the form object closes itself through the "Close" button, my reference is still there, set to .NULL. This is undesirable. I would like to be able to create objects completely on their own, with no references to them (I don't need to reference them, they each do their own thing).
>
>How can this be accomplished? I discovered that CREATEOBJECT() can be used on its own (not being assigned into a variable), so I tried something like this:
>
>WITH CREATEOBJECT('Form')
> .Show
>ENDWITH
>
>but it still must treat the un-named reference as LOCAL, since the form flashed and then disappeared (I was surprised it worked at all...)
>
>I know I can accomplish a more manageable result by using an object or public array that controls these references and such, but the main question remains..what about all the NULLs that are left over as forms close and reopen? Do I need to have a timer that explicitly releases references when they have been NULL for a certain time? You may ask why I am worried, as I certainly cannot have that many forms that open and close. But I do. All of the forms in my application are multi-openable, i.e. the patient screen can be open 4 different times with a different patient on each, and so on. After opening and closing 40 or 50 patients during one application session, there will be 40 or 50 NULLed-out PUBLIC form references sitting out there. Is this a problem? Do these pointers take any appreciable amount of memory or namespace?
>
>Bottom line: Can I have a form be created (and stay created) without having a public reference to it?
>
>Thanks for reading!
>
>JoeK
>jkaufman@encompas.com
Ken B. Matson
GCom2 Solutions
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform