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 #33496 is a reply to message #33495] Wed, 08 January 2003 05:01 Go to previous messageGo to previous message
Karsten Rodenacker is currently offline  Karsten Rodenacker
Messages: 98
Registered: July 1997
Member
s@visita2.die.upm.es schrieb:
> 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 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?
>
> Thanks for all tips,
>
> Sebastian
>

Try maybe

res=s.(where(strupcase(tag) eq tag_names(s))),/str

provided tag is really a tag name.

Regards

--
Karsten Rodenacker (LapTop)
------------------------------------------------------------ -------------:-)
GSF - Forschungszentrum Institute of Biomathematics and Biometry
D-85758 Oberschleissheim Postfach 11 29
Tel: +49 89 31873401 | FAX: ...3369 | Karsten@Rodenacker.de
http://www.gsf.de/ibb/
[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: Tue Dec 02 20:05:55 PST 2025

Total time taken to generate the page: 2.41049 seconds