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

Home » Public Forums » archive » Pointers
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Pointers [message #16663] Mon, 09 August 1999 00:00 Go to next message
rleejoice is currently offline  rleejoice
Messages: 2
Registered: August 1999
Junior Member
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?

TIA
Robert LeeJoice
Re: Pointers [message #16694 is a reply to message #16663] Sat, 14 August 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
J.D. Smith (jdsmith@astrosun.tn.cornell.edu) enlightens us
us with yet another interesting idea of how pointers can
be used. (But this time he uses a whimsical style, which
I haven't seen from J.D. in a while Oh, wait, it's Friday
night. He must of just gotten back from the weekly Astronomy
bash. :-)

In any case, I like his articles very much because I always
learn something from him. But I am confused by this first
statement:

> I would expand this step to include storing a copy of the pointer
> elsewhere, to eliminate the problem of dissappearing uvalues so common
> in non-blocking widget applications.

What disappearing uvalues!? I've never heard of this before,
and I like to think of myself as a worldly sort of guy. :-(

If the head is not too bad this morning, J.D., can you
elaborate a bit on what this is about? Many thanks.

Cheers,

David

P.S. I just tried that transmogrifying trick J.D. recommended.
It *is* karmic! :-)

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Pointers [message #16697 is a reply to message #16663] Sat, 14 August 1999 00:00 Go to previous message
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
L
> (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,

I would expand this step to include storing a copy of the pointer
elsewhere, to eliminate the problem of dissappearing uvalues so common
in non-blocking widget applications.

The best thing about pointers (and objects, for that matter) is that the
heap data they reference is global and persistent, but doesn't suffer
from the limitations of the common block. In fact, the treadworn common
block had new life breathed into by pointers: finally something to stick
into it which doesn't bloat your code and cause redefinition headaches.

One feature I use all the time with pointers is as follows: when saving
a data snapshot (actually, an object!) of interest, I can "detach" those
fragents of member data I don't need or want to save. Simply do
something like:

saved_ptr=self.BigAndUselessDataPtr ; detach
self.BigAndUselessDataPtr=ptr_new() ; a null pointer
save, self
self.BigAndUselessDataPtr=saved_ptr ; reattach

I actually wrap the whole thing in some error catching code to avoid
losing data but you get the point. This way, I can avoid saving class
definitions and member data of subsidiary objects and data structures I
don't want or need, and can keep my saved files relevant. And what
could be easier for saving a giant nested structure of structures of
pointers to arrays of structures containing pointer arrays (etc.) --
certainly I don't want to follow that mess along myself and save it bit
by bit.

(By the way, if you actually want to use this technique, please search
the archives for a thread entitled "Restoring Objects from file" or some
such.... there are a few issues to deal with -- not all of which David
has documented on his website. But nothing is more exciting than
replacing an object's "self" from one restored in place from file. It's
like reincarnation or identity transmogrification. Very kharmic.)

I could go on and on, but basically, the more you use pointers, the
happier you'll be (reminding me of a camp song there...)

Good Luck,

JD

--
J.D. Smith |*| WORK: (607) 255-5842
Cornell University Dept. of Astronomy |*| (607) 255-6263
304 Space Sciences Bldg. |*| FAX: (607) 255-5875
Ithaca, NY 14853 |*|
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: seperators in menus
Next Topic: Re: Keeping text Readable in Object Graphics

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

Current Time: Wed Oct 08 18:55:45 PDT 2025

Total time taken to generate the page: 0.00533 seconds