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

Home » Public Forums » archive » Re: getting structure elements by tag name string
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: getting structure elements by tag name string [message #33487] Wed, 08 January 2003 09:41 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
s@visita2.die.upm.es wrote:
> Hi all,
>
> I try to use a structure as a bad substitute for a hash map (hashs or
> associative lists or dictionaries or anything similar don't exist in
> IDL, do they?)
>
> Suppose I have a structure like this:
> s = {a:7,b:9}
>
> and I have a variable that contains a tag name:
> tag = 'a'
>
> Now I want to put the value of the structures element with name tag into a
> new variable called value:
> value = s.tag
>
> This doesn't work of course, because tag is undefined for this structure.
> But how can I get this the elements value?


I often use followings:

walue=s.(0)

for example is symbolic the firs tag of s.

You can extend this a bit more with a function of our library

value=s.(tag_position(s,'a'))


http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/tag_position.tar.gz

or as idl5.5 binary

http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/tag_position.sav


>
> I found a somewhat crude way:
> res = execute('value =' + 's.' + tag)
>
> That works, but it's really ugly. Is there a better way to do this?
>
> And, is there a way to delete an element from a structure?

Yes,

therefore we use delete_tag
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/delete_tag.tar.gz
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/delete_tag.sav

and just for interest you can add or replace or rename tags on each of
the structure levels.




For further routines and licensing please have a look at

http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html


best regards

Reimar
--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
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
============================================================ =======
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Getting running routine name
Next Topic: DataMiner

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

Current Time: Fri Oct 10 15:22:31 PDT 2025

Total time taken to generate the page: 0.80088 seconds