Posted by
ctrueden on
Mar 12, 2014; 9:57pm
URL: http://imagej.273.s1.nabble.com/Possible-to-call-a-javascript-script-or-function-w-arguments-from-a-macro-tp5006888p5006892.html
Hi Christophe,
> I have seen it, but how to pass an argument to the script?
You could pass args using string concatenation; e.g.:
eval("script", "print(" + myVariable + ")");
> I'd prefer to keep the javascript as a separate file because it is used
> outside the macro too.
OK, apparently the "runMacro" command can run JavaScript, too:
runMacro("/Users/curtis/Desktop/hi.js");
Where the contents of that file are:
IJ.showMessage("Hello!");
I figured that out by trying it with Plugins > Macros > Run with the Macro
Recorder active.
Regards,
Curtis
On Wed, Mar 12, 2014 at 3:21 PM, Christophe Leterrier <
[hidden email]> wrote:
> Hi Curtis,
>
> I have seen it, but how to pass an argument to the script? Plus, I'd prefer
> to keep the javascript as a separate file because it is used outside the
> macro too.
>
> Thanks,
>
> Christophe
>
>
> 2014-03-12 21:59 GMT+01:00 Curtis Rueden <
[hidden email]>:
>
> > Hi Christophe,
> >
> > > I'd like to know if it is possible to call some javascript from a macro
> >
> > Did you see the eval("script", javascript) method?
> >
http://imagej.net/developer/macro/functions.html#eval> >
> > -Curtis
> >
> >
> > On Wed, Mar 12, 2014 at 2:36 PM, Christophe Leterrier <
> >
[hidden email]> wrote:
> >
> > > Hi,
> > >
> > > I'd like to know if it is possible to call some javascript from a macro
> > in
> > > ImageJ. What I want to do is call the javascript, passing some
> arguments
> > to
> > > it (like a filepath), let it run, and return to the macro for further
> > > processing. How should I proceed ?
> > >
> > > Thanks for your help,
> > >
> > > Christophe
> > >
> > > --
> > > Christophe Leterrier
> > > Researcher
> > > Axonal Domains Architecture Team
> > > CRN2M CNRS UMR 7286
> > > Aix Marseille University, France
> > >
> > > --
> > > ImageJ mailing list:
http://imagej.nih.gov/ij/list.html> > >
> >
> > --
> > ImageJ mailing list:
http://imagej.nih.gov/ij/list.html> >
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html