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

Home » Public Forums » archive » Problem combining 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
Problem combining structures [message #26554] Fri, 07 September 2001 10:45
Jacco de Zwart is currently offline  Jacco de Zwart
Messages: 4
Registered: May 1998
Junior Member
Hi,

I have a problem combining two structures, which contain different tag
names, if one of them is a structure-array. Example:

### I make three structures: aa, bb and cc
IDL> aa={a:1,b:2}
IDL> bb={c:aa}
IDL> cc=replicate(bb,10)
IDL> help,aa,bb,cc
AA STRUCT = -> <Anonymous> Array[1]
BB STRUCT = -> <Anonymous> Array[1]
CC STRUCT = -> <Anonymous> Array[10]

### Assume I want to make a structure which combines aa and bb
IDL> dd=create_struct(aa,bb)
IDL> help,dd,/str
** Structure <8237944>, 3 tags, length=8, refs=1:
A INT 1
B INT 2
C STRUCT -> <Anonymous> Array[1]
### This obviously works fine

### However, combinging aa and cc in this way doesn't work
IDL> dd=create_struct(aa,cc)
% CREATE_STRUCT: Expression must be a scalar in this context: CC.
% Execution halted at: $MAIN$

### I can however generate the result that I want manually
IDL>
dd=create_struct([tag_names(aa),tag_names(cc)],aa.(0),aa.(1) ,cc.(0))
IDL> help,dd,/str
** Structure <8238934>, 3 tags, length=44, refs=1:
A INT 1
B INT 2
C STRUCT -> <Anonymous> Array[10]

### Loopwise adding elements of one structure to the other also doesn't
work:
IDL>
dd=cc
IDL> for i=0,1 do dd=create_struct(dd,(tag_names(aa))[i],aa.(i))
% CREATE_STRUCT: Expression must be a scalar in this context: DD.
% Execution halted at: $MAIN$

This was done in IDL 5.3 under Linux. Does anyone know how to do this?

Thanks in advance for your help!

Jacco de Zwart
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: object graphics to postcript and how to copy an object tree
Next Topic: Re: structure information

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

Current Time: Wed Oct 08 16:00:45 PDT 2025

Total time taken to generate the page: 0.00457 seconds