Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AddObject/RemoveObject
Message
From
22/03/2002 10:03:38
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00635975
Message ID:
00636028
Views:
25
>>>>I posted this first as a reply to Hilmar, as the original thread was marked as answered, I'm reposting as a new problem - apologies to those who've already read it.
>>>>
>>>>Following Hilmar's advice & FAQ #8110, I'm adding obects to an array on a form. This is all working as per the FAQ. Now, I'm trying to add further functionality & have found the following problem. If I add an object with a specific name & then remove it then the object disappears from the screen & the Destroy method is called :
>>>>
>>>>
>>>>thisform.addobject( "NewObj1", "MyObject" )
>>>>thisform.removeobject( "NewObj1" )
>>>>
>>>>
>>>>If I use the technique described in the faq, thus :
>>>>
>>>>
>>>>thisform.addobject( "thisform.alabels(3)", "MyObject" )
>>>>thisform.removeobject( "thisform.alabels(3)" )
>>>>
>>>>
>>>>then the object does not disappear from the screen & the Destroy method is not called. thisform.alabels(3) is set to .F.
>>>>
>>>>I'm guessing the object is not correctly destroyed, giving the possibility of a 'memory leak'. Does anyone know how I should correctly remove the objects added into the array.
>>>
>>>All objects created this way have the same name as an array 'alabels'. The RemoveObject method requeres the name of control as a patrameter and "thisform.alabels(3)" isn't the name of control. Issuing thisform.removeobject( "alabels") multiple times will remove the objects one by one.
>>
>>It seems to be a problem with the addobject method allowing an "illegal" object name ie alabels(3), converting it to something acceptable & then not raising an error when further objects are added. So there's multiple objects with the same name & no error generated.
>>
>>After all these years of working with VfP, I should have known that there was not going to be an easy solution.
>
>I think I provided one in my reply to Hilmar.

For which thanks, I may even be able to do away with the need for the additional array, all I need is the unique name.
Len Speed
Previous
Reply
Map
View

Click here to load this message in the networking platform