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

Home » Public Forums » archive » dereferencing a pointer to a complex structure?
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
dereferencing a pointer to a complex structure? [message #43417] Mon, 11 April 2005 08:14 Go to next message
zuzucat@gmail.com is currently offline  zuzucat@gmail.com
Messages: 4
Registered: April 2005
Junior Member
I have a troulbe dereferencing a pointer to a complex structure.

multidata = replicate({ grds:ptr_new(findgen(nx, ny))}, n_level)
data = replicate({time:0, level:multidata}, obs)
I
DL> print, (*data[3].level[3].grds)[0,4]
4.00000

ptr_data = ptr_new(data)

I tried (*(*data[3].level[3].grds))[0,4], but it doesn't work.

Any help would be appreciated.
best,

Nobuki Matsui
CDC/NOAA
Re: dereferencing a pointer to a complex structure? [message #43481 is a reply to message #43417] Tue, 12 April 2005 15:48 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Tue, 12 Apr 2005 12:57:46 -0700, zuzucat@gmail.com wrote:

> Mr. Chris Torrence at RSI kindly phoned my supervisor to tell us the
> answer.
>
> Thank you very much, all.
>
> print, (*(*ptr_data)[3].level[3].grds)[0,4]
> best,

This is exactly how the tutorial tells you to do it (even though this
isn't the question you had asked).

The easy to remember, basic rule from the tutorial: group with (*xxx)
all "xxx" which are pointers, unless the () would then occur on the
"outside" of the expression (it wouldn't hurt, it's just a waste).

So in your case the pointer "ptr_data" must be treated this way:

(*ptr_data)

as must the pointer "(*ptr_data)[3].level[3].grds":

(*(*ptr_data)[3].level[3].grds)[0,4]

if you didn't want to subscript the final FINDGEN, you could just use:

*(*ptr_data)[3].level[3].grds

JD
Re: dereferencing a pointer to a complex structure? [message #43482 is a reply to message #43417] Tue, 12 April 2005 13:24 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Yeah, but unless I'm missing something, this doesn't
> answer the original question. :-)

Or, maybe it does. Let's just say *I* won't be building
any data structures that look like this anytime soon. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: dereferencing a pointer to a complex structure? [message #43483 is a reply to message #43417] Tue, 12 April 2005 13:19 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
zuzucat@gmail.com writes:

> Mr. Chris Torrence at RSI kindly phoned my supervisor to tell us the
> answer.
>
> Thank you very much, all.
>
> print, (*(*ptr_data)[3].level[3].grds)[0,4]

Yeah, but unless I'm missing something, this doesn't
answer the original question. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: dereferencing a pointer to a complex structure? [message #43484 is a reply to message #43417] Tue, 12 April 2005 12:57 Go to previous message
zuzucat@gmail.com is currently offline  zuzucat@gmail.com
Messages: 4
Registered: April 2005
Junior Member
Mr. Chris Torrence at RSI kindly phoned my supervisor to tell us the
answer.

Thank you very much, all.

print, (*(*ptr_data)[3].level[3].grds)[0,4]
best,

Nobuki Matsui
Re: dereferencing a pointer to a complex structure? [message #43488 is a reply to message #43417] Tue, 12 April 2005 12:30 Go to previous message
Benjamin Hornberger is currently offline  Benjamin Hornberger
Messages: 258
Registered: March 2004
Senior Member
David Fanning wrote:
> David Fanning writes:
>
>
>> Yeah, never could I. :-(
>
>
> Say, what!? I'm getting ready to return to Germany for another
> couple of months. This must be what happens when the ol' German
> language CDs get the dust brushed off them. :-(

Oh, I can't wait to read more about your adventures!

Benjamin
Re: dereferencing a pointer to a complex structure? [message #43489 is a reply to message #43417] Tue, 12 April 2005 12:26 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Yeah, never could I. :-(

Say, what!? I'm getting ready to return to Germany for another
couple of months. This must be what happens when the ol' German
language CDs get the dust brushed off them. :-(

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: dereferencing a pointer to a complex structure? [message #43491 is a reply to message #43417] Tue, 12 April 2005 12:18 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
zuzucat@gmail.com writes:

> I've read this page, but I couldn't apply the info to this particular
> example.

Yeah, never could I. :-(

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: dereferencing a pointer to a complex structure?
Next Topic: structure access using strings for tag-names

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

Current Time: Thu Oct 09 16:03:00 PDT 2025

Total time taken to generate the page: 4.12597 seconds