|
|
|
Re: confusion around a pointer to an array of structures [message #45146 is a reply to message #45000] |
Tue, 09 August 2005 13:07  |
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
|
|
|
|