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

Re: Structures:

Chris Bull wrote:
> Hi all,
> A question regarding IDL structures, I have  an application that I am
> writing that I am using a very complex
> structure as a Uvalue to hold my data in, as this application evolves I am
> wondering  whether it
> is possible to add 'branches' to a structure after it is defined (and set as
> a uvalue), from within a seperate subroutine?
> I'm Thinking along the lines of describing an application that can hold many
> data sets, of different types in memory
> and load them up seperatly (much like a imaging program or multiple
> documents in word) except the data sets are
> very complex and of differing structures
> Any Ideas?

Yes it's possible if you have anonymous structure.

the trick is to store all structure levels to a string  vector 
and all tagvalues to a vector of pointers.
Then the new values in both are inserted and the structure is
new generated.

This is quite fast.

For example add_tag

;   d = {A: 1, B: {B1: 0, B2: 1}, C: {B1: 0, B2: 1}}
;   help,d,/str
;   ** Structure <1331608>, 3 tags, length=10, refs=1
;   A               INT              1
;   B               STRUCT    -> <Anonymous> Array[1]
;   C               STRUCT    -> <Anonymous> Array[1]

;   result = add_tag(d, 'ASA', 11, sub = 'B')
;   HELP, result.b, /STR
;   ** Structure <133ce88>, 3 tags, length=6, refs=1
;   B1              INT              0
;   B2              INT              1
;   ASA             INT             11

;   result = add_tag(d, 'BSB', {C11: INDGEN(3)}, sub = 'B.B3')
;   HELP, result.b, /STR
;   ** Structure <1357758>, 3 tags, length=10, refs=2:
;   B1              INT              0
;   B2              INT              1
;   B3              STRUCT    -> <Anonymous> Array[1]

Please have a look at the following routines. 


For further routines and licensing please look at

Reimar Bauer 

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
a IDL library at ForschungsZentrum Jülich