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

Home » Public Forums » archive » Re: Arrays of Structures
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Arrays of Structures [message #20468 is a reply to message #20465] Wed, 21 June 2000 00:00 Go to previous messageGo to previous message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
Ben Tupper <tupper@seadas.bigelow.org> wrote in message
news:39511D37.96A7BF8B@seadas.bigelow.org...
> 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.ne


Because they are not identical. They are not the same "type" of
structure, where by "type" I mean they get different tags.
IDL> help,s1,s2,/st
** Structure <1321598>, 3 tags, length=16, refs=2:
A INT 0
B FLOAT 0.100000
C STRING ''
** Structure <13272f8>, 3 tags, length=16, refs=1:
A INT 3
B FLOAT 7.00000
C STRING 'x'

Here the names are different (<1321598> and <13272f8>), so presumably IDL
does not know they are the same structure (I guess they don't do the
overhead of
parsing thorugh the structure to see if they really are the same).

Note that you can do the following (i.e. you can replace a structure element
if
it has the same tag):
; make the structure different
A.c ='bob'
print,a
A[1] = S1
print,a


Cheers.
bob
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Questions on External Development examples
Next Topic: A (too?) simple question about importing data

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

Current Time: Wed Oct 08 17:24:58 PDT 2025

Total time taken to generate the page: 0.00361 seconds