Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need to nuke objects in Destroy?
Message
From
26/08/2009 16:56:11
 
 
To
26/08/2009 16:29:45
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01405727
Message ID:
01421019
Views:
53
>>>P.S. -- this will end up being only a few lines of code anyway. You need help fleshing them out?
>>
>>
>>As I suspected, there's the "few lines of code" approach, and then there's the NASA aprroach per Christof's message # 1420860.
>>
>>So, sure, I'd love to see your few lines solution. It sure seems like a good little method to have on your base form class for a quick way to clean things up.
>>
>>Otherwise, I'll just hard-code the 3 properties that I know need to be released.
>
>Make a mental note to just add the fourth there too, when you have it. Once that becomes a habit, it's easy :).


Yes, Yes. I know... I have far too many of these habits under my belt already!

But, nope! Not this time. Thankfully, I will *NOT* hard-code *THIS* one, because my good friend Jim Nelson banged me out a very nice method to handle exactly what is called for, which I now share with all of UT and the rest of the VFP world (with his permission):
*--------------------------------------------------------------------------------
* Method form_base.PrepareObjectForDestroy()
*--------------------------------------------------------------------------------
Lparameters toObject

Local laMembers[1], lcMember, lnI

AMembers(laMembers, toObject, 1, 'PHG#')
With toObject
      For lnI = 1 to Alen(laMembers, 1)
            lcMember = laMembers(lnI, 1)
            If 'O' = Left(lcMember,1);
                        and laMembers(lnI,2) = 'Property'  ;
                        and not 'N' $ laMembers(lnI,3)       ;
                        and 'O' = Type ("." + lcMember)
                  Try
                        .&lcMember. = .Null.
                  Catch
                  EndTry
            endif
      endfor
endwith             
.
Previous
Reply
Map
View

Click here to load this message in the networking platform