Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Weird thing about .Destroy
Message
From
08/11/1997 10:51:37
 
 
To
07/11/1997 14:43:49
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00058959
Message ID:
00059079
Views:
35
>>>>>>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 could use the Name option of the DO FORM command but ofcouse
this presupposes that you have the name of your form in your nav-buttons.

Dan
>>>
>>>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.
>
>I wouldn't use neither form property, nor macro substitution. I would just split my code. Again, it's question of personal preference. If you like your approach, and it works, then it's the best way to do.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform