[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. 

 
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_html/dbase/download/replace_tagvalue.tar.gz
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_html/dbase/download/add_tag.tar.gz
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_html/dbase/download/rename_tag.tar.gz
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_html/dbase/download/delete_tag.tar.gz

For further routines and licensing please look at
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.html


-- 
Reimar Bauer 

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
=============================================
a IDL library at ForschungsZentrum Jülich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.html

http://www.fz-juelich.de/zb/text/publikation/juel3786.html