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

Home » Public Forums » archive » Re: newbie question / concatenation of arrays of nested structure
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: newbie question / concatenation of arrays of nested structure [message #17048 is a reply to message #17047] Wed, 08 September 1999 00:00 Go to previous messageGo to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
Thomas Launey wrote:
> how can I concatenate 2 arrays of anonymous nested structures?
> In other word, try to concatenate the two arrays below
>
> first=replicate({a:0,b:'name',c:{d:0,e:0}},5)
> second=replicate({a:0,b:'name',c:{d:0,e:0}},3)
> third=[first,second]
> % Conflicting data structures: B,concatenation.
> % Execution halted at: $MAIN$

Since first and second are anonymous structures, IDL has no way of
knowing that they contain the same fields, e.g.

IDL> first = replicate({a:0,b:'name',c:{d:0,e:0}},5)
IDL> second = replicate({a:0,b:'name',c:{d:0,e:0}},3)
IDL> help, first, /structure
** Structure <1373ab8>, 3 tags, length=16, refs=1:
A INT 0
B STRING 'name'
C STRUCT -> <Anonymous> Array[1]
IDL> help, second, /structure
** Structure <13734c8>, 3 tags, length=16, refs=1:
A INT 0
B STRING 'name'
C STRUCT -> <Anonymous> Array[1]

You can see that the structure ids are different (1373ab8 vs. 13734c8).
IDL uses the structure id to determine if structures are equivalent.

The only way to create equivalent structures is to use named structures,
e.g.

IDL> record = {z, a:0, b:'name', c:0}
IDL> first = replicate(record, 5)
IDL> second = replicate(record, 3)
IDL> combo = [first, second]
IDL> help, first, /structure
** Structure Z, 3 tags, length=16:
A INT 0
B STRING 'name'
C INT 0
IDL> help, second, /structure
** Structure Z, 3 tags, length=16:
A INT 0
B STRING 'name'
C INT 0

Now first and second have the same structure id (z), and they can be
concatenated. Note that IDL does not like nested anonymous structures
inside a named structure, e.g.

IDL> record = {x, a:0, b:'name', c:{d:0, e:0}}
% Structures can't have anonymous structure members
% Execution halted at: $MAIN$

so you may have to re-think your original record format.

Cheers,
Liam.

--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Nautical Miles to Lat/Lon Degrees
Next Topic: Updates to SAVEIMAGE and SHOWIMAGE

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

Current Time: Sun Oct 12 10:43:45 PDT 2025

Total time taken to generate the page: 0.23810 seconds