I don't know if this counts as elegant, but I use code similar to this
at one point. And yeah, it's a "for" loop...
emptyObject: function( obj, dest )
{
local tot, i;
local list := obj.contents;
if ( itemcnt ( list ) )
{
tot := ( length( list ) );
for( i := 1; i <= tot; i++ )
list[ i ].moveInto( dest );
}
}
Note that I'm lazy and haven't tested this exact piece of code - I took
an existing function of mine, pulled out a bunch of lines that are specific
to my own class libraries, and left the rest. So this isn't the most
efficient way to code it, and hey - it may not work. I think it will
though...
What it's supposed to do is take the listable contents of a given object
(obj) and transfer them to the destination - dest. Note that I'm using
the itemcnt() adv.t function, as this function isn't meant to move
non-takeable objects.
- Neil K.
-- Neil K. Guy * neilg@sfu.ca * tela@tela.bc.ca 49N 16' 123W 7' * Vancouver, BC, Canada