Login  Register

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

Posted by Albert Cardona-2 on Mar 16, 2011; 12:15pm
URL: http://imagej.273.s1.nabble.com/continue-equivalent-on-macro-language-for-loop-control-tp3685375p3685377.html

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


Carnë,

Macro recording and macros in general are great for specific tasks
that can be applied to individual images, and are suitable for batch
processing. For complex programs I'd go for a language that makes
shuffling data around easy. For example python.

Here is a tutorial on using python with Fiji, an ImageJ distribution
packed with many libraries and plugins:

  http://www.ini.uzh.ch/~acardona/fiji-tutorial/

Hope that helps.

Albert

--
http://albert.rierol.net