[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Pointers
- To: RLeejoice <rleejoice(at)aol.com>
- Subject: Re: Pointers
- From: Liam Gumley <Liam.Gumley(at)ssec.wisc.edu>
- Date: Mon, 09 Aug 1999 14:03:08 -0500
- Newsgroups: comp.lang.idl-pvwave
- Organization: Space Science and Engineering Center, University of Wisconsin-Madison
- References: <19990809113204.24776.00008727@ng-ft1.aol.com>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:16045
RLeejoice wrote:
> Been using IDL for a year. Want to expand into what I feel are three last
> topics of interest; pointers, widgets, and object graphics.
>
> I've read the entire pointer section of the help file and have the following
> question:
>
> What are pointers used for in IDL. I only precieve that they lead to the new
> object paradyme. Is this correct? I use structures in most of my programming
> and pass the complete structure to the appropaite procedures. I suppose I
> could creat a pointer to a structure, but since IDL passes structures by
> reference, what is the need?
There are at least two cases I know of where pointers are indispensable:
(1) When the size and/or type of an item contained in a structure is not
known until runtime (you cannot change the size or type of a variable in
a structure). For example, say you have a widget program with a large
information structure. At some point in the widget program, you want to
be able to select sub-regions of an image and store the data from the
selected regions (e.g. to save it to file elsewhere in the program). The
most convenient way to save this data in the information structure is to
use an array of pointers, where each pointer in the array points to the
data for each selected region.
(2) When you wish to return information from a dying widget. If you want
a widget program to return an item of information, then it must be
passed in a variable which has global scope. A pointer is the most
convenient way to pass this kind of information. The method is
- Create the information structure,
- Store the information structure using a pointer,
- Store the pointer in the user value of the widget top level base,
- Invoke XMANAGER to handle widget events with the CLEANUP keyword set
to the name of the routine to be called when the top level widget dies,
- In the cleanup routine, save whatever information is required via the
pointer,
- After XMANAGER is done, retrieve the information from the pointer.
Cheers,
Liam.
--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley