[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Oddball Event Handling (Longer than it Ought to Be)




Hi David--

Thanks for the cool description of you project.

Now, prepare to be lightly toasted :-)

> FUNCTION FindTLB, startID
> 
> ; This function traces up the widget hierarchy to find the top-level base.
> 
> FORWARD_FUNCTION FindTLB
> parent = Widget_Info(startID, /Parent)
> IF parent EQ 0 THEN RETURN, startID ELSE parent = FindTLB(parent)
> RETURN, parent
> END

I have no problem with recursion.  In this case however it's not
really needed.  For the book larnin' types, this is known as tail
recursion I believe, which is often easily optimized.  I admit
recursion may help you conceptualize what's going on though.  Wouldn't
the following code do the same thing?

parent = startid
while widget_info(parent, /parent) NE 0 do $
  parent = widget_info(parent, /parent)

Craig


-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------