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

Home » Public Forums » archive » Re: use of loops in IDL for hashtable
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
Re: use of loops in IDL for hashtable [message #67893] Mon, 07 September 2009 20:35
b.a is currently offline  b.a
Messages: 26
Registered: July 2009
Junior Member
On Sep 8, 12:36 pm, pp <pp.pente...@gmail.com> wrote:
> On Sep 7, 11:16 pm, "b.a" <u4565...@anu.edu.au> wrote:
>
>
>
>
>
>> On Sep 7, 6:08 pm, Wox <s...@nomail.com> wrote:
>
>>> On Sun, 6 Sep 2009 19:01:06 -0700 (PDT), "b.a" <u4565...@anu.edu.au>
>>> wrote:
>
>>>> Hi,
>
>>>> I have 2 hashtables in my IDL program. one is called fileList which
>>>> has ( id , data ) as its (key, value) and second one is colorList
>>>> ( id , color ). I want to define a "foreach" loop so that for each id
>>>> of colorList which exists in fileList, it plots the data with the
>>>> "color". I mean for each string "id" get the "data" from fileList and
>>>> get the "color" from colorList and plot the data in that colour.
>
>>>> Can anybody help me with this please.
>
>>>> Thank you
>
>>> Are you using Craig Markwardt's hash table object? This object has a
>>> method "KEYS" which returns all existing keys in a hash table, so you
>>> can loop over all keys in colorList (or fileList), use "ISCONTAINED"
>>> to check whether the key is in fileList (or colorList) and do your
>>> plotting when it is (employing the Get method to get data and color).
>
>> Thanks for your reply.
>> Yes, I am using Craig Markwardt's hash table object. The problem with
>> using KEY() is that the keys are not like {1, 2, 3, 4, ...} that I can
>> loop over them. they are like {76, 65, 90, 2, 503, ...}. and I don't
>> know the largest key. I have to say for i=0 till some number, go i+1
>> and if i+1 is contained in the keys, return its value and rest of the
>> things. but I can't specify that "some number". So I think I have to
>> use "for each" loop. But I don't know the syntax for it in my case.
>
> KEYS() returns an array of key names. So you loop over the elements of
> this array. Something like:
>
> colorkeys=colorList->keys()
> for i=0,n_elements(colorkeys)-1 do if fileList->iscontained(colorkeys
> [i]) then *do stuff*- Hide quoted text -
>
> - Show quoted text -


Thanks a lot!
Re: use of loops in IDL for hashtable [message #67894 is a reply to message #67893] Mon, 07 September 2009 19:36 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Sep 7, 11:16 pm, "b.a" <u4565...@anu.edu.au> wrote:
> On Sep 7, 6:08 pm, Wox <s...@nomail.com> wrote:
>
>
>
>> On Sun, 6 Sep 2009 19:01:06 -0700 (PDT), "b.a" <u4565...@anu.edu.au>
>> wrote:
>
>>> Hi,
>
>>> I have 2 hashtables in my IDL program. one is called fileList which
>>> has ( id , data ) as its (key, value) and second one is colorList
>>> ( id , color ). I want to define a "foreach" loop so that for each id
>>> of colorList which exists in fileList, it plots the data with the
>>> "color". I mean for each string "id" get the "data" from fileList and
>>> get the "color" from colorList and plot the data in that colour.
>
>>> Can anybody help me with this please.
>
>>> Thank you
>
>> Are you using Craig Markwardt's hash table object? This object has a
>> method "KEYS" which returns all existing keys in a hash table, so you
>> can loop over all keys in colorList (or fileList), use "ISCONTAINED"
>> to check whether the key is in fileList (or colorList) and do your
>> plotting when it is (employing the Get method to get data and color).
>
> Thanks for your reply.
> Yes, I am using Craig Markwardt's hash table object. The problem with
> using KEY() is that the keys are not like {1, 2, 3, 4, ...} that I can
> loop over them. they are like {76, 65, 90, 2, 503, ...}. and I don't
> know the largest key. I have to say for i=0 till some number, go i+1
> and if i+1 is contained in the keys, return its value and rest of the
> things. but I can't specify that "some number". So I think I have to
> use "for each" loop. But I don't know the syntax for it in my case.

KEYS() returns an array of key names. So you loop over the elements of
this array. Something like:


colorkeys=colorList->keys()
for i=0,n_elements(colorkeys)-1 do if fileList->iscontained(colorkeys
[i]) then *do stuff*
Re: use of loops in IDL for hashtable [message #67895 is a reply to message #67894] Mon, 07 September 2009 19:16 Go to previous message
b.a is currently offline  b.a
Messages: 26
Registered: July 2009
Junior Member
On Sep 7, 6:08 pm, Wox <s...@nomail.com> wrote:
> On Sun, 6 Sep 2009 19:01:06 -0700 (PDT), "b.a" <u4565...@anu.edu.au>
> wrote:
>
>> Hi,
>
>> I have 2 hashtables in my IDL program. one is called fileList which
>> has ( id , data ) as its (key, value) and second one is colorList
>> ( id , color ). I want to define a "foreach" loop so that for each id
>> of colorList which exists in fileList, it plots the data with the
>> "color". I mean for each string "id" get the "data" from fileList and
>> get the "color" from colorList and plot the data in that colour.
>
>> Can anybody help me with this please.
>
>> Thank you
>
> Are you using Craig Markwardt's hash table object? This object has a
> method "KEYS" which returns all existing keys in a hash table, so you
> can loop over all keys in colorList (or fileList), use "ISCONTAINED"
> to check whether the key is in fileList (or colorList) and do your
> plotting when it is (employing the Get method to get data and color).

Thanks for your reply.
Yes, I am using Craig Markwardt's hash table object. The problem with
using KEY() is that the keys are not like {1, 2, 3, 4, ...} that I can
loop over them. they are like {76, 65, 90, 2, 503, ...}. and I don't
know the largest key. I have to say for i=0 till some number, go i+1
and if i+1 is contained in the keys, return its value and rest of the
things. but I can't specify that "some number". So I think I have to
use "for each" loop. But I don't know the syntax for it in my case.

Cheers
Re: use of loops in IDL for hashtable [message #67904 is a reply to message #67895] Mon, 07 September 2009 01:08 Go to previous message
Wout De Nolf is currently offline  Wout De Nolf
Messages: 194
Registered: October 2008
Senior Member
On Sun, 6 Sep 2009 19:01:06 -0700 (PDT), "b.a" <u4565723@anu.edu.au>
wrote:

> Hi,
>
> I have 2 hashtables in my IDL program. one is called fileList which
> has ( id , data ) as its (key, value) and second one is colorList
> ( id , color ). I want to define a "foreach" loop so that for each id
> of colorList which exists in fileList, it plots the data with the
> "color". I mean for each string "id" get the "data" from fileList and
> get the "color" from colorList and plot the data in that colour.
>
> Can anybody help me with this please.
>
> Thank you

Are you using Craig Markwardt's hash table object? This object has a
method "KEYS" which returns all existing keys in a hash table, so you
can loop over all keys in colorList (or fileList), use "ISCONTAINED"
to check whether the key is in fileList (or colorList) and do your
plotting when it is (employing the Get method to get data and color).
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Help, no improvement in FFT speed on a multiprocessor system
Next Topic: checking the data type in IDL

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

Current Time: Wed Oct 08 19:05:19 PDT 2025

Total time taken to generate the page: 0.00687 seconds