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

Home » Public Forums » archive » Re: Pointer syntax and IDL 4.0
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
Re: Pointer syntax and IDL 4.0 [message #28527] Wed, 19 December 2001 13:59 Go to next message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
tam wrote:
>
> Recently I upgraded the a couple of routines to use pointers
> in certain special cases. However the pointer dereference operator
> is illegal prior to version 5.0, so the code fails to compile on
> older versions of IDL -- though the great majority of the code is still
> useful there. It would be nice to be able to use a single
> version of code to support all users, so I'm asking the question:
> Is there any way of addressing this, i.e., dereferencing a pointer
> in a way that will not cause a syntax error for earlier versions of IDL?
>
> An obvious solution would be if there were a dereferencing function
> as well as an operator...
>
> x = ptr_val(some_pointer)
>
> would be the same as
>
> x = *some_pointer
>
> but I don't think IDL supplies one. If I write this one-liner
> myself, I may reduce the number of errors in the code to one
> but I'd prefer to make it completely transparent...
>

I recall Liam had some tools for this:

http://cimss.ssec.wisc.edu/~gumley/pointers.html

We recently had some trouble converting legacy handles to pointers. It
sounds like a trivial transformation, but here are the sticky spots:

1. Handles are long integers, pointers have their own special variable
type.

2. A good test for handle validity is "if handle ne 0L". This will
fail miserably for pointers, where "if ptr_valid(ptr)" is the
equivalent.

3. Handle storage slots in structures, object, etc. will consist of a
long integers. This will need to be changed to pointers to avoid
errors.

So, simple scripts which convert handle->pointer will typically not be
effective, since they cannot account for the variety of ways handles are
treated as simple long integers in practice.

Maybe we should just go back to using uvalues of unpopulated base
widgets. (OK, I admit, that was actually before my time... we can
solicit the full story from David).

Good luck,

JD
Re: Pointer syntax and IDL 4.0 [message #28530 is a reply to message #28527] Wed, 19 December 2001 13:11 Go to previous messageGo to next message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
tam <tam@lheapop.gsfc.nasa.gov> writes:


> Recently I upgraded the a couple of routines to use pointers
> in certain special cases. However the pointer dereference operator
> is illegal prior to version 5.0, so the code fails to compile on
> older versions of IDL -- though the great majority of the code is still
> useful there. It would be nice to be able to use a single
> version of code to support all users, so I'm asking the question:
> Is there any way of addressing this, i.e., dereferencing a pointer
> in a way that will not cause a syntax error for earlier versions of IDL?

Try using an EXECUTE() statement. We've used that on occasion when
version-dependent code causes compilation problems.

Bill Thompson
Re: Pointer syntax and IDL 4.0 [message #28531 is a reply to message #28530] Wed, 19 December 2001 13:01 Go to previous messageGo to next message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
Obviously one can live just fine without spending a fortune on upgrades :)

tam wrote:
>
> Is there any way of addressing this, i.e., dereferencing a pointer
> in a way that will not cause a syntax error for earlier versions of IDL?

It depends on how far back the code has to be backward compatible. Isn't
earlier IDL totally lacking pointers?
I'd look up !Version.Release in the code and use IF statements to switch
to Handles syntax.

Cheers,
Pavel
Re: Pointer syntax and IDL 4.0 [message #28532 is a reply to message #28531] Wed, 19 December 2001 13:07 Go to previous messageGo to next message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
tam wrote:
>
> Recently I upgraded the a couple of routines to use pointers
> in certain special cases. However the pointer dereference operator
> is illegal prior to version 5.0, so the code fails to compile on
> older versions of IDL -- though the great majority of the code is still
> useful there. It would be nice to be able to use a single
> version of code to support all users, so I'm asking the question:
> Is there any way of addressing this, i.e., dereferencing a pointer
> in a way that will not cause a syntax error for earlier versions of IDL?
>
> An obvious solution would be if there were a dereferencing function
> as well as an operator...
>
> x = ptr_val(some_pointer)
>
> would be the same as
>
> x = *some_pointer
>
> but I don't think IDL supplies one. If I write this one-liner
> myself, I may reduce the number of errors in the code to one
> but I'd prefer to make it completely transparent...
>
> Any ideas?

Have a lookie at:

http://cimss.ssec.wisc.edu/~gumley/pointers.html


--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
Re: Pointer syntax and IDL 4.0 [message #28615 is a reply to message #28532] Wed, 19 December 2001 15:36 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Paul van Delst <paul.vandelst@noaa.gov> writes:

> tam wrote:
>>
>> Recently I upgraded the a couple of routines to use pointers
>> in certain special cases. However the pointer dereference operator
>> is illegal prior to version 5.0, so the code fails to compile on
...
>> Any ideas?
>
> Have a lookie at:
>
> http://cimss.ssec.wisc.edu/~gumley/pointers.html

Paul is right. Liam's code will work in IDL 4 and 5, and provides an
interface that works under both versions of IDL too. Under IDL 4
there are no pointers, but "handles" are used instead, which have
basically the same functionality. Basically you use POINTER_CREATE,
POINTER_VALUE and POINTER_FREE in place of the normal pointer
operations, and you are done.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: generic text box window
Next Topic: RE: David Stern Leaves RSI

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

Current Time: Wed Oct 08 18:39:14 PDT 2025

Total time taken to generate the page: 0.00644 seconds