[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help with pick menu widget code
- Subject: Re: Help with pick menu widget code
- From: davidf(at)dfanning.com (David Fanning)
- Date: Wed, 16 Sep 1998 08:33:31 -0600
- Newsgroups: comp.lang.idl-pvwave
- Organization: Fanning Software Consulting
- References: <35FF1250.CC986831@REMOVECAPSloki.srl.caltech.edu> <MPG.firstname.lastname@example.org> <email@example.com>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:12164
Rose Longfield writes:
> I wasn't able to solve Doug's problem. I found the Uvalue error but could
> not understand why the Widget ID was not valid, when, every time I printed it
> it had a number that matched the event.top.
> That's because I was looking in the wrong place! As David Fanning astutely
> pointed out, the error was in the SET command at the bottom of the program,
> FAR away from where I thought it was.
When you have taught as many IDL courses as I have both of these
common errors just sort of jump out at you. :-) But if you get
an error message that a pointer (or info) structure is not defined,
there are only about three things that could be wrong: (1) You didn't
copy it into the program module (the problem here, but the least likely
error in my experience), (2) You forgot to put the pointer (or info
structure) into the UValue of the TLB (the most likely possibility), or
(3) you took it out with a NO_COPY, but failed to put it back before
you exited the module. (The last problem should occur only with info
structures. You shouldn't be copying pointers, as I pointed out
> The message from XMANAGER states simply: % XMANAGER: Caught unexpected error
> from client application. Message follows... % WIDGET_CONTROL: Invalid widget
> identifier: 61.
I agree that this is a cryptic message, although one I see so often
when people are writing their first widget programs that I know the
solution almost without thinking about it now. I do remember struggling
for an hour or so the first time it happened to me, however.
> There are widget controls all over the code, is there any way for XMANAGER to
> be a little more helpful about identifying, WHICH widget_control was causing
> the error?
Let me give you a tip for solving errors like this a little
more easily. The XManager routine has a CATCH statement in it.
The way error handling in IDL works is that if there is a CATCH
statement anywhere along the "program trace" (I don't know a
good way to say this, but if one program calls another and that
program calls another, you are now three programs deep in the
"trace"), then the error gets handled by that CATCH statement.
What you really want is for the error in your widget program to
propagate all the way up to the main IDL level, where IDL will
attach a line number to the error. Then, at least, you will know
what line of code caused the error, if not what the error
To make the error propagate all the way up, you have to turn
any CATCH error handling off in the module that is causing
the error, and you have to turn it off for XManager. You
do this by typing this command on the IDL command line
*before* you run your program:
IDL> XManager, Catch=0
Now when you run the program, you get this error message:
% WIDGET_CONTROL: Invalid widget identifier: 3.
% Execution halted at: PICKFINISH_EVENT 323 C:\RSI\IDL51\david\junk.pro
I can go to line 323 in my code and try to figure out why the only
widget identified there (event.top) is somehow invalid. It may
only take me a half-hour to realize that I just killed the sucker. :-)
P.S. Rose, are you coming to my October course in Denmark?
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
Coyote's Guide to IDL Programming: http://www.dfanning.com/