; EXAMPLE:
; d = {A: 1, B: {B1: 0, B2: 1}, C: {B1: 0, B2: 1}}
;
; result = delete_tag(d, 'B')
; help, result, /str
; ** Structure <1342678>, 2 tags, length=8, refs=1:
; A INT 1
; C STRUCT -> <Anonymous> Array[1]
;
; result = delete_tag(d, ['B*'], SUB = 'C')
; help, result, /str
; ** Structure <13694a8>, 2 tags, length=6, refs=1:
; A INT 1
; B STRUCT -> <Anonymous> Array[1]
;
; result = delete_tag(d, '*B1', SUB = ['B', 'C'])
; help, result.b, /str
; ** Structure <1331be8>, 1 tags, length=2, refs=1:
; B2 INT 1
;
; result = delete_tag(d, ['B1', 'B2'], /ALL)
; help, result, /str
; ** Structure <170fac8>, 1 tags, length=2, refs=1:
; A INT 1
;
; help,(delete_tag(d,'b1',sub_structure='B')).b,/str
; B2 INT 1
;
; help,delete_tag(d,'B',/all)
; ** Structure <140aa40>, 2 tags, length=6, refs=1:
; A INT 1
; C STRUCT -> <Anonymous> Array[1]
;
; help,(delete_tag(d,'b1',sub_structure='B')).c,/str
; ** Structure <1333618>, 2 tags, length=4, refs=1:
; B1 INT 0
; B2 INT 1
;
; help,(delete_tag(d,'*',sub_structure='B')),/str
; ** Structure <133b2d8>, 2 tags, length=6, refs=1:
; A INT 1
; C STRUCT -> <Anonymous> Array[1]
;
; help,(delete_tag(d,'*',sub_structure='B',/sort)),/str
; ** Structure <d40daa8>, 2 tags, length=6, refs=1:
; A INT 1
; C STRUCT -> <Anonymous> Array[1]
;
; help,(delete_tag(d,sub_structure=['B','A'])),/str
; ** Structure <132fe78>, 2 tags, length=6, refs=1:
; A INT 1
; C STRUCT -> <Anonymous> Array[1]
;
; help,(delete_tag(d,sub_structure=['B','C'])),/str
; ** Structure <1333288>, 1 tags, length=2, refs=1:
; A INT 1
;
; help,(delete_tag(d,['B1','B2'],sub_structure=['B','C'])),/st r
; ** Structure <46a9498>, 1 tags, length=2, refs=1:
; A INT 1
;
; d = {ABRA: {B1: 0, B2: 1}, ABRA2B: {B1: 0, B2: 1}, ABRA3B: {B1: 0,
B2: 1}}
;
; result=delete_tag(d,'abra')
; help,result,/str
; ** Structure <1365a48>, 2 tags, length=8, refs=1:
; ABRA2B STRUCT -> <Anonymous> Array[1]
; ABRA3B STRUCT -> <Anonymous> Array[1]
;
; result=delete_tag(d,'abra*')
; help,result,/str
; RESULT INT = -1
;
; result=delete_tag(d,'abra?B')
; help,result,/str
;
; ** Structure <1364358>, 1 tags, length=4, refs=1:
; ABRA STRUCT -> <Anonymous> Array[1]
;
; d = {ABRA: {B1: 0, B2: {A:1}}, ABRA2B: {B1: 0, B2: {A:1}}, ABRA3B:
{B1: 0, B2: {A:1}}}
; result=delete_tag(d,'A',sub_structure='abra.b2')
; help,result.abra,/str
; ** Structure <1365c68>, 1 tags, length=2, refs=2:
; B1 INT 0
;
Reimar Bauer wrote:
> M. Katz wrote:
>
>> I was wondering if there's a simple way to remove a field from a
>> structure?
>>
>> I can envision a manual way:
>> 0) creating a new structure variable for the result
>> 1) reading the original's tag names
>> 2) stepping through tag by tag using indexed value references, like a.
>> (i)
>> 3) using create_struct() to put the tags and values into the new
>> structure, one by one, except for the tag(s) we're removing.
>>
>> Does anyone have a more elegant suggestion?
>> M. Katz
>>
>
>
> Hi
>
>
> so here are some very fast ones based on pointer operations which do
> work on sub structures too
>
> delete_tag
> http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/delete_tag_dbase.pro.html
>
> add_tag
> http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/add_tag_dbase.pro.html
>
> replace_tag_value
> http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/replace_tagvalue_dbase.pro.html
>
> rename_tag
> http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/rename_tag_dbase.pro.html
>
>
> If you like to read examples in german may be you are interested in
> reading a book about our library
> http://www.fz-juelich.de/zb/datapool/page/439/00322_Bauer.pd f
>
> cheers Reimar
>
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
|