Re: Structures and COMMON blocks [message #6026 is a reply to message #6025] |
Wed, 10 April 1996 00:00  |
Ken Knighton
Messages: 44 Registered: May 1995
|
Member |
|
|
Phil Williams <williams@irc.chmcc.org> wrote:
> I'm developing several widget based apps and have a question concerning
> the use of structures and common blocks.
>
> I have found both of these invaluable, but the problem comes when I want
> to add a variable to a common block or structure. When I try to
> recompile the .pro file idl won't let me. Is there another way to do
> this other than quitting IDL and starting it over?
You can add fields to anonymous structures using CREATE_STRUCT. You
can not change the definition of a named structure.
As for common blocks, I don't know of any way to change a common block
definition in the current IDL session. That means you have to exit
IDL and get back in.
This might sound like a burden, but, except in special cases where you
want to have a "static" value in a routine, you don't need to use common
block variables. Instead, you can save information into an anonymous
structure and then store the structure in a widget's uvalue and retrieve
it at will. For examples of this, see the compound widgets supplied
with IDL such as CW_FIELD.
If you really need to have a variable common block, then you can
define a common block variable as a structure and simply add fields to
the structure using CREATE_STRUCT.
IDL> common xyz_com, sGlobal
IDL> sGlobal = {a:5, b:'xyz'}
IDL> print, sGlobal
{ 5 xyz}
IDL> sGlobal = CREATE_STRUCT(sGlobal, 'c', 7.5)
IDL> print, sGlobal
{ 5 xyz 7.50000}
>
> Along this theme, is there a way to "uncompile" a procedure or function
> so that IDL forgets about it?
I am not aware of any.
I hope this helps.
Ken Knighton knighton@cts.com
San Diego, CA
|
|
|