global variables again - and passing out common blocks [message #11603] |
Tue, 28 April 1998 00:00 |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
Hi,
This is how fast things change. Here I was doubting the necessity to
pass global variables back from a routine, and now this is what I am
stuck with:
I tried to add two features to my EXPLORE tool, but it turns out that
only one of them works at a time:
(1) upon exit: extract the data of the last active window, store it as a
heap variable in a common block and return it to the main program (if a
named variable was passed as a keyword)
(2) use the /NO_BLOCK keyword to xmanager to have the command line
available
The trouble lies in the program flow: without /NO_BLOCK, IDL
continues program execution after the call to xmanager when the widget
is closed, so there is a chance to do additional things in the
mainprogram (like retrieving the pointer information). However, with
/NO_BLOCK set, IDL runs through the main program (pro explore)
completely, and when exiting the widget application, you only get a call
to the cleanup routine, but there is no way to pass anything out any
more except "activating" the common block EPOINTERS in $MAIN$ which
leads to a bit of trouble described below and makes it mandatory to
manually free the pointers if you don't need them. Any better idea is
greatly appreciated.
Another problem, which I consider a real bug, is related to common
blocks: if you define a common block inside a subroutine and you want to
make it accessible to $MAIN$, you are in bad luck if you had issued a
HELP command on any variable in the common block before. Example:
pro test
common testcom,a
a=10
end
IDL>test
IDL>help,a
A UNDEFINED = <Undefined>
IDL>common testcom
% A is already defined with a conflicting definition.
; if it says "undefined" before, how can it be "defined" now ?
; It works after delvar,a !
Regards,
Martin.
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA
phone: (617)-496-8318
fax : (617)-495-4551
e-mail: mgs@io.harvard.edu
IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/
------------------------------------------------------------ -------
|
|
|