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

Home » Public Forums » archive » Newbie Questions
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
Newbie Questions [message #25039] Tue, 15 May 2001 07:42 Go to next message
Geoff Herbynchuk is currently offline  Geoff Herbynchuk
Messages: 6
Registered: May 2001
Junior Member
Hi,

Was just wondering if IDL can have pointers to structures. I'm trying to
access a variable in the structure with:

if (*info).active_cursor EQ 1) then .....

And I keep getting an error which says "Expression must be a structure in
this context: <PtrHeapVar57>."

Does anyone know what I'm doing wrong?

Thanks,
Geoff Herbynchuk
Re: Newbie Questions [message #25091 is a reply to message #25039] Fri, 18 May 2001 04:25 Go to previous message
Alex Schuster is currently offline  Alex Schuster
Messages: 124
Registered: February 1997
Senior Member
Geoff Herbynchuk wrote:

> And, if we do:
>
> bar_ptr = ptr_new(bar, /no_copy)
>
> bar_ptr will now just point to the memory location where bar is stored
> (not copy it to a heap location)? We can then update the bar, or the
> components of bar(if bar is a structure) by dereferencing bar_ptr,
> right?

Wrong :( With /no_copy, bar becomes undefined, because its value is
taken away and being attached directly to bar_ptr.


> For example:
>
> *bar_ptr.name = 'Geoff'

Caution, this would be (*bar_ptr).name, because bar_ptr is the pointer,
not bar_ptr.name.


> Thanks for everyone's help. I've only worked with pointers in
> C/C++ before, and I'm getting the impression that these don't work
> exactly the same way. =)

Correct. In C, they are real pointers to a memory location. In IDL, they
are just a heap variable. Tricks like p=&a, *p=5 to set a to 5 will not
work in IDL.
You can, however, set bar2_ptr = bar_ptr, and now at least these two
point to the same value, and *bar2_ptr = 0 also sets *bar_ptr to 0.

Alex
--
Alex Schuster Wonko@weird.cologne.de PGP Key available
alex@pet.mpin-koeln.mpg.de
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: only valid numbers in arrays
Next Topic: color table conversion

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

Current Time: Wed Oct 08 15:16:39 PDT 2025

Total time taken to generate the page: 0.00506 seconds