>>Dear All,
>>
>>I append several objects programmatically, how can I remove it "automatically"?
>>e.g.
>>
>>nEditBox1
>>nEditBox2
>>nEditBox3... nEditBox999
>>
>>How can I issue a command to remove them all?
>>
>>
>>FOR x = 1 TO 999
>> nLabel = EVALUATE([nEditBox]+TRANSFORM(x))
>> f_form.removeobject(nLabel)
>>ENDFOR
>>
>>
>>However, I don't know how many EditBox I added beforehand...?!
>
>If they're from same class you can brodacast a message to tell them to remove themselves. ie:
>
>*Custom property Action
>*Action_assign
>lparameters vNewVal
>if vNewVal='destroy' and type('this.parent')='O'
> this.parent.RemoveObject(this.name)
>endif
>
>thisform.SetAll('Action','destroy','myClass')
>
Cetin
Hi Cetin,
when I have seen this code
I thought that VFP collapsed with two or more objects,
because when it remove the first one,
all the indexes of the collection move back him of one
(the collections of VFP are implemented as array,
and this is a coarse error,
correct implementation it is with a linked list ....)
but enough an only object to make to collapse VFP,
because when VFP goes out of Broadcast_Assign all the pointers C++ they are corrupt,
and when the routine c++ looks for the following one it goes out a violation of memory.
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
DEFINE CLASS form1 AS form
ADD OBJECT tx2 AS tx WITH ;
Left = 79, ;
Top = 115, ;
Name = "Tx2"
PROCEDURE Click
Thisform.SetAll("BroadCast",.f.)
ENDPROC
ENDDEFINE
DEFINE CLASS tx AS textbox
broadcast = .F.
HIDDEN PROCEDURE broadcast_assign
LPARAMETERS vNewVal
this.Parent.RemoveObject(this.Name)
WAIT WINDOW "don't touch nothing or me I die"
ENDPROC
ENDDEFINE