Login  Register

Re: macro - array elements as options in run()

Posted by Jan Eglinger on Jan 28, 2016; 11:53am
URL: http://imagej.273.s1.nabble.com/macro-array-elements-as-options-in-run-tp5014112p5015473.html

Hi Gabriele,

you have to use string concatenation in the correct way. The 'y=' and
'x=' are parts of the option string, the values you want to assign are
given by the sin() function:

     t = newArray(0, 30, 60, 90);
     for (i=0; i<t.length; i++) {
         run("Translate...", "interpolation=None slice y=" + sin(t[i]) +
" x=" + cos(t[i]) );
     }


Hope that helps,
Jan


On 28.01.2016 12:30, karvek wrote:

> Hi all,
>
> I have the same problem of Ved but in my case the array is a sequence of
> number that I would like to use in a run command.
>
> Very short, something like:
> t = newArray(0, 30, 60, 90);
> for (i=0, i++) {
> run("Translate...", "interpolation=None slice y=sin(t[i]) x=cos(t[i]");
> }
>
> By using &t[i] there is no way to execute the Macro properly.
> If I use "+t[i]+" then the value number is read as a string and cannot
> perform my operation.
>
> Anyone have any clue how to do this?
> Thanks.
>
> Gabriele
>

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