[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Oddball Event Handling (Longer than it Ought to Be)
- Subject: Re: Oddball Event Handling (Longer than it Ought to Be)
- From: Craig Markwardt <craigmnet(at)cow.physics.wisc.edu>
- Date: 31 Dec 2000 09:45:33 -0600
- Newsgroups: comp.lang.idl-pvwave
- Organization: U. Wisc. Madison Physics -- Compact Objects
- References: <MPG.14b8681e8daad5f6989cd6@news.frii.com>
- Reply-To: craigmnet(at)cow.physics.wisc.edu
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:22781
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
--------------------------------------------------------------------------