Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Weird thing about .Destroy
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00058959
Message ID:
00058968
Vues:
37
>>>>I have a nav button class which had some references to THISFORM.DataEnvironment. Of course, it was hosed when I dropped it into a form that was in a formset. So, I gave the navclass a property "oFormOrSet", and in a navclass method called from the .Init, I put this:
>>>>
>>>>
>>>>* Figure out if it's a form or a formset,
>>>>* set everything accordingly
>>>>
>>>>IF TYPE("THISFORMSET") = "O"
>>>> THIS.oFormOrSet = THISFORMSET
>>>>ELSE
>>>> THIS.oFormOrSet = THISFORM
>>>>ENDIF
>>>>
>>>>I used it to say things like .oFormOrSet.DataEnvironment. But when I needed it in the navclass.Destroy to clean up things in the DE, my reference was gone, even though THISFORMSET or THISFORM still existed. So I had to do something similar in the navclass.Destroy with a local variable:
>>>>
>>>>* the object reference THIS.oFormOrSet
>>>>* seems to have been detroyed, even though
>>>>* the form or formset still exists
>>>>IF TYPE("THISFORMSET") = "O"
>>>> oFormThis = THISFORMSET
>>>>ELSE
>>>> oFormThis = THISFORM
>>>>ENDIF
>>>>
>>>>
>>>>and then used it to say oFormThis.DataEnvironment. Is it really supposed to be this way?
>>>
>>>Personally, I would prefer to use Parent property to reach DE at the code point when it's really necessary (using TYPE(), of course). I try to abstain from using object reference variables/properties, just because it smells like invitation to troubles...
>>
>>How would you "use Parent property to reach DE"? I mention the DE in several places.
>
>You age going from some object on form, right? So, you first check Thisform.DE.Name or This.Parent.DE.Name. If its type is not "O", then you have thisformset and use This.Parent.Parent.DE or Thisform.Parent.DE

And then you put the name in a form property? Like this:
THIS.cFormName = THISFORMSET.Name or THISFORM.Name, whichever is appropriate? Then I suppose you use name substitution or macro substitution wherever you mention the DE, like (THIS.cFormName).DataEnvironment or whatever syntax works? I certainly don't want to check for the existence of a formset every time I mention the DE.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform