stuh505
03-10-2006, 11:18 PM
Hey guys,
I am trying to do some recursive deleting and max is being really finnicky...can't seem to get it to work.
I have a structure which has an array field 'children', which can be filled with any number of the same type of structure, ad infinitum.
Some of these structures might be flagged for deletion, so I have to recursively traverse the DAG of structures, looking for anyone that is flagged and deleting all structures below if I find one that is flagged...
When I find a structure that is flagged, I need to know the index of that structure in the structure above it in order to delete it. So, I can't use "for c in children".
Instead, I am using a while loop...this seems to crash max immediately, it does not seem to like me deleting something from the array while I am iterating over it
fn checkForDeleteBelow=
(
c = 1
while c <= children.count do
(
if children[c].deleteFlag then
(
children[c].deleteBelow()
if (children[c].shape != undefined) then
delete children[c].shape
deleteItem children c
) else
(
children[c].checkForDeleteBelow()
c += 1
)
)
)
I am trying to do some recursive deleting and max is being really finnicky...can't seem to get it to work.
I have a structure which has an array field 'children', which can be filled with any number of the same type of structure, ad infinitum.
Some of these structures might be flagged for deletion, so I have to recursively traverse the DAG of structures, looking for anyone that is flagged and deleting all structures below if I find one that is flagged...
When I find a structure that is flagged, I need to know the index of that structure in the structure above it in order to delete it. So, I can't use "for c in children".
Instead, I am using a while loop...this seems to crash max immediately, it does not seem to like me deleting something from the array while I am iterating over it
fn checkForDeleteBelow=
(
c = 1
while c <= children.count do
(
if children[c].deleteFlag then
(
children[c].deleteBelow()
if (children[c].shape != undefined) then
delete children[c].shape
deleteItem children c
) else
(
children[c].checkForDeleteBelow()
c += 1
)
)
)
