Re: Newbie Questions [message #25036] |
Tue, 15 May 2001 12:21  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Geoff Herbynchuk <gherbyn@irus.rri.on.ca> writes:
> 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?
Umm, are you sure that INFO points to a structure? I tried it and it
worked fine. (see below). Why not put a "HELP, *INFO, /STRUCT" right
before this statement and see what pops up?
IDL> struct = {active_cursor: 1}
IDL> info = ptr_new(struct)
IDL> help, (*info).active_cursor
<Expression> INT = 1
IDL> help, info
INFO POINTER = <PtrHeapVar1>
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
|
|
Re: Newbie Questions [message #25109 is a reply to message #25036] |
Thu, 17 May 2001 05:15  |
Geoff Herbynchuk
Messages: 6 Registered: May 2001
|
Junior Member |
|
|
Thanks for the help guys, got that problem fixed. I'm hoping you can help
me with one more thing with IDL pointers.
When we do something like:
foo_ptr = ptr_new(foo)
foo_ptr points to a memory location in the heap memory that contains
foo's value, correct? So, am I safe to assume it copys whatever the value of
foo is into the heap variable that foo_ptr is pointing too?
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?
For example:
*bar_ptr.name = 'Geoff'
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. =)
Geoff Herbynchuk
|
|
|