[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arrays of Structures



Jared wrote:

> Ben,
>
> An array of anonymous structures can be made.  For example:
>
> a = replicate( {a:0, b:.1, c:''}, 10)
>
> makes a 10 element array of anonymous structures.  Hope this helps.
>
> Jared

Thanks,

Ah, that was easy!

Now here's 'How come #2'
I know that I can replace a given field in one of the structures.
How come I can't replace Array element X with an identical structure (as
I would with a named structure?)


IDL> S1 =  {a:0, b:.1, c:''}
IDL> S2 = {a:3, b:7., c:'x'}
IDL> A = Replicate(S1,3)
IDL> A(1).c = 'q'                 ;replace a field value without a
problem
IDL> A[1] = S2                    ; can't replace a structure.
% Conflicting data structures: S2,A.
% Execution halted at:  $MAIN$

Thanks,
Ben

--
Ben Tupper

Bigelow Laboratory for Ocean Science
tupper@seadas.bigelow.org

pemaquidriver@tidewater.net