Re: traversing hierarchical nested output from dbGetTrueOverlaps



On May 22, 2:54 am, "S. Badel" <stephane.ba...@xxxxxxxxxxxxxxxxx>
wrote:
<snip>
instances = dbGetOverlaps( cv bBox nil 32 )

Then each element in the result will be either
(a) an instance (or mosaic) id, or
(b) a list. ; in this case the car of the list will the containing instance, and the cdr will be
either (a) or (b) in turn

The bottomline is, if you're not going to use the hierarchical path, then the element you are
searching for is always the leaf ; i.e. it is the only element which is not a list.

Therefore

foreach( elem instances
while(listp(elem) elem=cadr(elem))
when( elem~>cellName == "myCell"
printf("I found a myCell\n")
) ; when
) ; foreach


Clever, this works good. I "think" I get it. If I might say some more
to make sure I am understanding.

So the dbGetOverlaps returns the following, basically a list of
elements that contain either...
a) an atom (instance id or mosiac) which is the object that is at the
top level
and/or
b)nested list

A example of a dbGetOverlaps return value would be:

(dbid1 (dbid1 dbid2) (dbid1(dbid2 dbid3)))

Where dbid1 might be "TOP" cell, and dbid2 might be "SUB1" cell, and
dbid3 might be "SUB2", where TOP is at top level hierarchy, SUB1 would
be one level down, and SUB2 would be 2 levels down.

<snip>

Hope this can inspire you for your code. Cheers,

Stéphane

Excellent, this is very helpful, and inspiring. I will also check out
your recursion example, but I wanted to make sure I was understanding
dbGetOverlaps return value first. Thanks for your time and insight.
.