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

Home » Public Forums » archive » Re: global variables in IDL
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: global variables in IDL [message #28654 is a reply to message #28649] Tue, 25 December 2001 09:25 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gert (gert.van.de.wouwer@NO_SPAMpandora.be) writes:

> I want to keep some global variables in an IDL program containing different
> widgets without having to pass the variables each time a new base widget is
> created. It can be done with common blocks, but then you can have only 1
> instance of the program running.
> I was thinking of creating a widget (called Globals) and copy the variables
> in a struct to its uvalue. If another widget then wants these variables, I
> need to get a widget identifier to Globals and retrieve the struct. But how
> can I get this widget identifier?

It's odd, isn't it, how good ideas keep being rediscovered
over and over again. :-)

It sounds like what you need is, uh, a pointer!

IDL> info = Ptr_New({all_your_stuff_in_here}, /No_Copy)

Then, when you create your widgets, you simply
pass the pointer to each program that needs it:

IDL> widget_program_1, info
IDL> widget_program_2, info
IDL> widget_program_3, info

The syntax of using pointers to structures is a little
weird until you get used to it:

TV, (*info).image, Order=(*info).order

Alternatively, you can create your pointer in the first
widget program, and pass it to the other programs that
are called from the first, etc. There are lots of ways
to do it, but all rely on a pointer of some sort.

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Gridding Gui
Next Topic: Inverting the image

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

Current Time: Thu Oct 09 07:02:34 PDT 2025

Total time taken to generate the page: 0.87977 seconds