Login  Register

Re: Multiple initializations in a for loop

Posted by Stefan Helfrich-2 on May 06, 2016; 5:58am
URL: http://imagej.273.s1.nabble.com/Multiple-initializations-in-a-for-loop-tp5016325p5016326.html

Hey Vad,

from the ImageJ documentation at
http://rsb.info.nih.gov/ij/developer/macro/macros.html#loops:
> The initialization is a statement that runs once at the beginning of
> the loop.
So the macro language does not support multiple initialization
statements in one loop. You'll have to work around it per your
suggestion or move to another language (see http://imagej.net/Scripting
for example).

All the best,
Stefan

On 5/6/16 5:38 AM, Ved Sharma wrote:

> Hi all,
>
> I received an error when I tried to have multiple initializations in a for loop. Does macro language not support multiple initializations?
>
> Here is the macro I was trying:
>
> for(i=2, str="1"; i<=5; i++)
> str = str+","+toString(i);
> print(str);
>
> The macro works fine (prints 1,2,3,4,5), if I pull one of the initializations (str="1") out of the for loop.
>
> Thanks!
>
> Ved
> ___________________________________
> Ved Sharma, PhD
> Department of Anatomy and Structural Biology
> Albert Einstein College of Medicine
> Bronx, New York
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
Stefan Helfrich, M.Sc.
Bioimaging Center (L931)
University of Konstanz

PO Box 604
78457 Konstanz
Germany

Tel +49-7531-884666
Fax +49-7531-884005


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html