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

Home » Public Forums » archive » Re: IDL V5 and Pointers
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: IDL V5 and Pointers [message #9619] Wed, 23 July 1997 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Charles Martin writes:

> I just started using pointers in IDL. Does anyone know how to get create a
> pointer that points to an existing variable, without duplicating the
> variable and without making it undefined?
>
> For example:
>
> x=findgen(1000,1000,1000) ; a big array
> ptr=ptr_new()
> ptr=&x ; this syntax is derived from C and is not valid in IDL.

It is not possible to create a pointer in IDL that points to
an existing variable without either (1) duplicating the variable, or
(2) making the variable undefined.

The reason for this, of course, is that IDL pointers are not
machine pointers like they are in C. That is to say, they
do not point directly to machine memory. They are special
heap variables, a way to have pointer-like operators in IDL
without the subsequent technical support nightmare real
machines pointers would cause.

Most of the time the distinction is completely moot.
For example, I might write the code above like this:

x = Ptr_New(Findgen(1000,1000,1000))

Then everywhere in the code where you use x I would
use *x. This makes it virtually transparent to the user.

Cheers,

David

------------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
Customizable IDL Programming Courses
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
IDL 5 Reports: http://www.dfanning.com/documents/anomaly5.html
[Message index]
 
Read Message
Previous Topic: Directory of Software Development Professionals
Next Topic: DIALOG_PICKFILE PROBS

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

Current Time: Thu Oct 09 23:07:03 PDT 2025

Total time taken to generate the page: 2.00084 seconds