Thank you for your reply.
How about the following script? The script repeats the parent function until it reaches the top parent.
nw = New Window( "test",
pb1 = Panel Box( "1",
pb2 = Panel Box( "2",
pb3 = Panel Box( "3",
H List Box(
Spacer Box( 100 ),
tb4 = Text Box( "4" ),
V List Box(
tb5 = Text Box( "5" ),
Spacer Box( Size( 100, 100 ) ),
tb6 = Text Box( "6" )
)
)
)
)
)
);
//count parent display box from target to top display box
count parent = Function( {nw, target, top}, //window, target display box, top display box
top_parent = top;
end = 0;
current = target;
displaybox_list = {};
For( i = 1, And( end == 0, i < 100 ), i++,
parent = current << parent();
If( Is Empty( parent ),
end = 1,
current = parent;
Insert Into( displaybox_list, current );
If( top_parent == current,
end = 1
);
);
);
Eval List( {i - 1, displaybox_list} );
);
{count, displaybox_list} = count parent( nw, tb6, pb1 );
show(count);