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

Home » Public Forums » archive » getting structure elements by tag name string
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
getting structure elements by tag name string [message #33497] Wed, 08 January 2003 03:03 Go to next message
s[1] is currently offline  s[1]
Messages: 21
Registered: December 2002
Junior Member
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
Re: getting structure elements by tag name string [message #33534 is a reply to message #33497] Thu, 09 January 2003 11:55 Go to previous message
dscherba is currently offline  dscherba
Messages: 1
Registered: January 2003
Junior Member
In article <3E1DAF62.487FB29F@hotmail.com>, Pavel A. Romashkin wrote:

> arrays? They do create indices, true, but still they serch them somehow,
> and that is fast. I'd say the speed is size-dependent, but it doesn't
> seem to be linearly proportional.

Different database systems use different methods, but all of them are
sub-linear in some sense (if they weren't, there would be little point
in indexing). Common methods are hash tables (essentially constant
lookup), and various search trees (balanced k-ary search trees have a
lookup time of O(log n)). In the real world(tm) things get a bit
messier, but that's the idea.

As for the original query, I have been known to use the EXECUTE()
function to get my structure elements by tag string.

Regards,
David
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Lost EXPONENT
Next Topic: Re: Getting running routine name

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

Current Time: Wed Oct 08 13:43:50 PDT 2025

Total time taken to generate the page: 0.00390 seconds