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

Home » Public Forums » archive » Re: Empty FOREACH loop
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: Empty FOREACH loop [message #75107 is a reply to message #75101] Mon, 14 February 2011 19:08 Go to previous messageGo to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
I also get the temporary variables stuff, and agree that things like

foreach el,!null do print,el
foreach el,[] do print,el
foreach el,{} do print,el

Should all do nothing, with no errors.

But if foreach is given a named variable that is !null it does nothing
as expected:

IDL> n=!null
IDL> foreach el,n do print,el
IDL>

On Feb 14, 9:47 pm, Michael Galloy <mgal...@gmail.com> wrote:
> I was quite surprised when the following raised an error for me:
>
> IDL> foreach g, [] do help, g
> % Variable is undefined: <UNDEFINED>.
> % Execution halted at: $MAIN$
>
> Does this seem like unexpected behavior? I was expecting the loop just
> not to execute.
>
> Of course, whatever the right answer is, it shouldn't do this (as it
> does on my Mac):
>
> IDL> foreach g, [] do help, g
> % Temporary variables are still checked out - cleaning up...
>
> Mike
> --www.michaelgalloy.com
> Research Mathematician
> Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: dialog_pickfile crashing IDLDE
Next Topic: Pointer and structure question

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

Current Time: Fri Oct 10 17:45:18 PDT 2025

Total time taken to generate the page: 0.56153 seconds