Re: continue equivalent on macro language (for loop control)
Posted by
Rainer M. Engel on
Sep 30, 2013; 12:46pm
URL: http://imagej.273.s1.nabble.com/Re-continue-equivalent-on-macro-language-for-loop-control-tp5004972p5004980.html
>> ImageJ 1.48d adds support for 'continue' and 'break' statements to the
>> macro language.
>>
>> -wayne
>>
Nice coincidence, I was in the mood of asking for that too. Thank you
Carnë and Wayne.
// loop functions (examples)
//+++++++++++++++++++++++++++++++++++++++++++++++++
a = newArray(0,0,0,1,0);
c = 0;
for (i=0; i<a.length; i++) {
//print(a[i]);
if (a[i] != 0) {
//continue; //continues to next element of loop
break; //breaks the loop and continues macro
}
print("element is: 0");
c++;
}
print("end of macro reached, "+c+" elements printed");
//+++++++++++++++++++++++++++++++++++++++++++++++++
Like Christophe wrote, there are other ways to skip elements inside a
loop but the new functions offer far better ways. Very nice..
Regards,
Rainer
--
Rainer M. Engel, Dipl. Digital Artist
scientific|Media GbR
Pichelsdorfer Str. 143
13595 Berlin
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html