Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Tip of the Day - a Way To Avoig Dangling Object Referenc
Message
De
05/11/1999 16:08:32
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00287529
Message ID:
00287788
Vues:
22
>>S'okay. :) Looking forward to it.
>
>Actually I just tested it.
>
>I have a form with a listbox, container and a button. In the button.Click()
>I call
>
>this.parent.container.testmethod("this.cHostName")
>
>The container has custom method .testmethod(),
>.cHostname property and .access_chostname() method for it.
>
>container.cHostName = "this.parent.list1" && reference to listbox
>
>*** container.access_chostname() method
>local loHost1
>IF !empty(this.cHostname)
>	loHost1 = eval(this.cHostname)
>	RETURN loHost1
>ENDIF	
>
>*** container.testmethod()
>LPARAMETER tcHostProperty
>Local loHost
>loHost = EVAL(tcHostProperty) && here is where container.access_chostname() fires
>loHost.ColumnCount = 3
>loHost.ColumnWidths = "20,20,20"
>***
>
>So, the button.click() passes the name of the container property which holds the reference name to the desired object.
>EVAL(tcHostProperty) causes the Access method to fire, (Access method may also check for existence of the object), and passes back the object reference. Then some processing takes place, after which the loHost variable automatically gets trashed as it is a local variable
>
>This was just a quick test that proves that it works, but I don't know yet if I am just complicating things... :)
>
>Nick

Ok. I think I've got the gist of what you are doing.

I remember that you could use access and assign at any level of a hierarchy.

I created a form and added a list a command button.

I added a poList property which will be the object reference in this case to the list box, including poList's access method.

In the access method I do the following.

RETURN EVAL( "THISFORM.List1" )

Now in the command button'c click event I have the following code:

=MESSAGEBOX( THISFORM.poList.Name )

Does this idea fall into the scheme of what you are doing, trying not to leave any dangling object references?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform