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 #33493 is a reply to message #33491] Wed, 08 January 2003 05:40 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
s@visita2.die.upm.es (s@visita2.die.upm.es) writes:

> 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?)

Humm. I guess I'm used to thinking of IDL as
nothing *more* than one giant hash map. Are you
familiar with the WHERE function, or with array
operations, in general?

> 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?

I should think so. Hash tables generally have ways to
add, delete, and find items. That almost sounds like
a linked list to me.

http://www.dfanning.com/programs/linked_list__define.pro

> And, is there a way to delete an element from a structure?

Do you mean delete a "field" from a structure? If you have
anonymous structures (see your "s" structure, above), then
you could just re-define your structure with that field:

s = (a:s.a}

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[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: Sat Oct 11 03:57:30 PDT 2025

Total time taken to generate the page: 1.51883 seconds