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

Home » Public Forums » archive » Re: confusion around a pointer to an array of structures
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: confusion around a pointer to an array of structures [message #44998] Tue, 09 August 2005 12:03 Go to next message
Henry is currently offline  Henry
Messages: 8
Registered: April 2005
Junior Member
If this group should ever hold a "dumbest question ever" contest, I
hereby self-nominate my above post.

-Henry
Re: confusion around a pointer to an array of structures [message #44999 is a reply to message #44998] Tue, 09 August 2005 11:57 Go to previous messageGo to next message
Henry is currently offline  Henry
Messages: 8
Registered: April 2005
Junior Member
Gak!!!!

Good grief. I could have sworn I'd tried every combo, but clearly
not.

I will now retreat shame faced, return my 9 or so years of IDL
programming experience to whence it came, and retire to goat farming.

Many thanks!
-Henry
Re: confusion around a pointer to an array of structures [message #45000 is a reply to message #44999] Tue, 09 August 2005 11:53 Go to previous messageGo to next message
Edd Edmondson is currently offline  Edd Edmondson
Messages: 50
Registered: January 2003
Member
Henry <henrygroe@yahoo.com> wrote:
> But, I can see no other way around this, aside from redesigning how I'm
> storing the information. Does anyone see how to do the equivalent of
> "((*a)[0]).x = 99d" in the above example? (without the awkward three
> line dumb hack I've shown)
> I'm sure I'm just not seeing something simple....

Is there anything incorrect about saying (*a)[0].x=99d ?

--
Edd
Re: confusion around a pointer to an array of structures [message #45146 is a reply to message #45000] Tue, 09 August 2005 13:07 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Edd wrote:
> Henry <henrygroe@yahoo.com> wrote:
>
>> But, I can see no other way around this, aside from redesigning how I'm
>> storing the information. Does anyone see how to do the equivalent of
>> "((*a)[0]).x = 99d" in the above example? (without the awkward three
>> line dumb hack I've shown)
>> I'm sure I'm just not seeing something simple....
>
>
> Is there anything incorrect about saying (*a)[0].x=99d ?
>

I tried the OP's method and got his error,

IDL> ((*a)[0]).x = 99d
% Attempt to store into an expression: Structure reference.
% Execution halted at: $MAIN$

and thought that the "correct" syntax would be something like ((*a).x)[0]

This is what I get,

IDL> a = ptr_new( replicate( {x:0d}, 5 ) )
IDL> (*a).x = dindgen(5)
IDL> help, ((*a).x)[0]
<Expression> DOUBLE = 0.0000000
IDL> ((*a).x)[0] = 99d
% Internal error: The Interpreter stack is not empty on exit.
IDL> help, ((*a).x)[0]
<Expression> DOUBLE = 99.000000

So that works too..... sort of.

Veird.

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Re: confusion around a pointer to an array of structures [message #45147 is a reply to message #44999] Tue, 09 August 2005 12:21 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Tue, 09 Aug 2005 11:57:57 -0700, Henry wrote:

> Gak!!!!
>
> Good grief. I could have sworn I'd tried every combo, but clearly
> not.

You might like to have a read of the operator precedence tutorial, which
provides a useful rule of thumb on when and where parentheses are
needed in this sort of situation:

http://www.dfanning.com/misc_tips/precedence.html

JD
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: On Unix IDL CD must mount with exec for install to work
Next Topic: confusion around a pointer to an array of structures

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

Current Time: Thu Oct 09 06:55:30 PDT 2025

Total time taken to generate the page: 0.56368 seconds