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

Home » Public Forums » archive » "foreach" loops in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
"foreach" loops in IDL [message #64806] Fri, 16 January 2009 10:30 Go to previous message
alaniwiusenet is currently offline  alaniwiusenet
Messages: 2
Registered: January 2009
Junior Member
In case anyone's interested, I've produced a little hack that lets you
have "foreach" loops in IDL, i.e. loop over the contents of an array.
It would be nice if the syntax were to let you have something like:

for myval in myarray do begin
print, myval
endfor

Unfortunately it doesn't, unless I've missed something somewhere. And
it's just a little fiddly to have to loop over an array index every
time, e.g.:

for i=0, n_elements(myarray) - 1 do begin
myval = myarray[i]
print, myval
endfor

The hack lets you use the following syntax:

foreach, 'myval', myarray
@do
print, myval
@done

and nested loops are supported.

If anyone is interested in having this, grab this a (tiny) download,
that contains a few short files to put somewhere in your IDL_PATH:

http://home.badc.rl.ac.uk/iwi/idl-foreach.tar.gz

Regards,
Alan

P.S. Please note that I do not read this mailbox. Do a web search for
"Alan Iwi" if you want my email address.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: A new version of GRAFFER
Next Topic: Re: Problems with array elements as parameter in c++ function used via call_external

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

Current Time: Thu Oct 09 22:00:32 PDT 2025

Total time taken to generate the page: 0.72016 seconds