comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Common block conumdrum
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Common block conumdrum [message #8440 is a reply to message #8355] Tue, 04 March 1997 00:00 Go to previous messageGo to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Daniel Williams wrote:
>
> When developing programs in IDL, I often work with common blocks.
> However, if I try to change the definition of an existing common
> block, I get an error because it IDL thinks that I am trying to use a
> pre-existing common block in a naughty manner. According to the
> user's manual (v3.6 p6-10) this is what IDL should do.
> However, when creating new programs, I often want to change the
> definition of the common block as the program developes. How can I do
> this, short of exiting IDL and starting over? Is there some "delvar"
> equivalent for deleting common blocks or programs from memory?

There are times when common blocks are very useful, such as when
you must share data between various programs. If you are using
common blocks so that you have "global" variables within a single
application, I would strongly suggest that you follow the example
presented in the User's Guide, Ch. 21 "Writing a Compound Widget",
and store the "state" information in the uvalue of the first
child of your main base. Then, in the event handler you can use:

stash = WIDGET_INFO( event.top, /child )
WIDGET_CONTROL, stash, get_uvalue = state, /no_copy

to retrieve this state structure. Then pass the structure to your
routines. See the example above for details.

This method is a little bit slower, but a lot cleaner and safer
(you don't have to worry about using "reserved" variable names and
overwriting something in the common block, for example).

If you really need a common block, then the suggestion by Phil
Williams to use a large structure as your first variable in the
common block is a good one; you can add tags to this structure as
you need them. This also avoids the problem of inadvertently re-using
common-block variables.

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2200
La Jolla, CA 92037
[ UCSD Mail Code 0949 ]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Command line history in IDLWAVE shell
Next Topic: Debugging overload

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 11:23:07 PDT 2025

Total time taken to generate the page: 0.56024 seconds