Impossible to exit a $MAIN$ program [message #69704] |
Sun, 31 January 2010 20:49 |
JDS
Messages: 94 Registered: March 2009
|
Member |
|
|
In performing a bit of IDLWAVE cleanup, I noticed something I hadn't
seen before (but which explains an annoyance I'd always had when
working with $MAIN$ routines): there is no apparent way to return from
a $MAIN$ program.
As an example, compile the following simple $MAIN$ program
; foo.pro
;======================
a=1
stop
do_not_set_or_you_will_explode=2
END
;======================
IDL> help,/trace
% At $MAIN$
IDL> .run foo
% Compiled module: $MAIN$.
% Stop encountered: $MAIN$ 2 /Users/jdsmith/code/idl/test/
foo.pro
IDL> retall
IDL> help,/trace
% At $MAIN$ 2 /Users/jdsmith/code/idl/test/foo.pro
The calling stack is "stuck" inside the main level program. The
*only* way out I can see is to .RETURN or .OUT (twice, for some
unknown reason):
IDL> help,/trace
% At $MAIN$ 2 /Users/jdsmith/idl/test/foo.pro
IDL> .out
IDL> help,/trace
% At $MAIN$ 1 /Users/jdsmith/idl/test/foo.pro
IDL> .out
% Starting at: $MAIN$
IDL> help,/trace
% At $MAIN$
IDL> print,do_not_set_or_you_will_explode
2
;; explodes
You see that is has the unwanted side effect of running through the
rest of the $MAIN$ program. I can find no way equivalent to RETALL
for named programs, which exits all the way to the top of the program
stack. Am I missing something, or is this a design (mis-)feature left
over from olden times. I would expect RETALL to return to the clean,
vanilla $MAIN$ level, not inside of any compiled $MAIN$ routines. If
you knew how much there was to skip you could .SKIP your way out, but
that's hardly automate-able.
Another oddity: once you are *out* of a $MAIN$, continued calls
to .OUT or .RETURN seem to drop you back *into* it at the same place
you stopped! I realize this won't make a difference to most people,
but IDLWAVE uses the output of help,/trace quite a bit, and it's
disconcerting when in a long-lived IDL session, the state of some old
throwaway $MAIN$ program you ran days or weeks ago keeps popping up.
JD
|
|
|