Login  Register

Re: continue equivalent on macro language (for loop control)

Posted by Carnë Draug on Mar 16, 2011; 11:10am
URL: http://imagej.273.s1.nabble.com/continue-equivalent-on-macro-language-for-loop-control-tp3685375p3685381.html

Hi Christophe,

it's just to avoid nesting code even more. Since the code is already
in another loop and there will be more if and loops in the analysis
part, if that could be avoided great. I'm more of a perl programmer so
I like my code clean and easy to read (hahahaha!)

But from your answer I'm guessing there's no way to do it, just as
there's no equivalent to the break statement. Can this mail maybe
count as a feature request?

Thanks anyway,
Carnë

2011/3/15 Christophe Leterrier <[hidden email]>:

> Hi,
> Hi Carnë,
> Why don't you put the "smart analysis" part inside the if(File.exist)
> condition, just after opening the file ? So it will not be done for non
> existing images and the outputn will be the same ? Or maybe I missed
> something.
> Christophe
>
> 2011/3/15 Carnë Draug <[hidden email]>
>>
>> Hi everyone,
>>
>> is there any equivalent to 'continue' in a for loop in the macro
>> language? I'm inside a foor loop and want to skip to the next value in
>> the loop if a certain condition is not meet. Here's a bit of code
>> example
>>
>> // get list of files and options
>>
>> for (i = 0; i < lengthOf(file_list); i++) {
>>  // check if file exists before opening. Skip if it's no longer there
>>   if(File.exists(file_list[i]) {
>>     file.open(file_list[i]);
>>   } else {
>>     print ("File disappeared. Skipping");
>>     continue;
>>   }
>>   // Do very smart image analysis here
>> }
>>
>> I tried continue and it doesn't work. "next" also doesn't. Any help
>> would be appreciated.
>>
>> Thanks in advance,
>> Carnë Draug
>
>