Macro.getOptions();

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Macro.getOptions();

ColinWhite
Hi,

Could someone explain how the Macro.getOptions() and the Macro.setOptions() commands work? I'm doing this, but options always returns null.

String options=Macro.getOptions();
Macro.setOptions(options);

I'm trying to get the user to input a file path in the arguments, such as:

run("Analyzer", "/Users/Colin/Desktop/Cell0024_img(Nisanth).txt");

Thanks,
Colin
Reply | Threaded
Open this post in threaded view
|

Re: Macro.getOptions();

Juanjo Vega
I pass arguments to my plugins from the command line using Macro.getOptions.

The way I do it is the following:

1) Create a macro to run plugin passing arguments to it:

 macro "MyMacro" {
    run("My plugin", getArgument);
 }


2) From my plugin, get and process arguments:

...
if (IJ.isMacro() && Macro.getOptions() != null && !Macro.getOptions().trim().isEmpty()) {
            processArgs(Macro.getOptions().trim());
}
...


3) Run plugin passing arguments to it:

java -Dplugins.dir=<imagejpluginsdir> -jar ij.jar -macro MyMacro.txt "file1 file2 file3 ... fileN"


It also works in the way IJ.run("My plugin","file1 file2 ...")
Maybe there is a better way to do that, but mine works.

Hope it helps.

Sincerely,

Juanjo.


On Aug 17, 2011, at 10:47 PM, ColinWhite wrote:

> Hi,
>
> Could someone explain how the Macro.getOptions() and the Macro.setOptions()
> commands work? I'm doing this, but options always returns null.
>
> String options=Macro.getOptions();
> Macro.setOptions(options);
>
> I'm trying to get the user to input a file path in the arguments, such as:
>
> run("Analyzer", "/Users/Colin/Desktop/Cell0024_img(Nisanth).txt");
>
> Thanks,
> Colin
>
> --
> View this message in context: http://imagej.588099.n2.nabble.com/Macro-getOptions-tp6697148p6697148.html
> Sent from the ImageJ mailing list archive at Nabble.com.

------------------------------------------------------------
Juanjo Vega ([hidden email])

Unidad de Biocomputación. Laboratorio B-13.
Centro Nacional de Biotecnología. CNB-CSIC.
C\ Darwin, 3. Campus de Cantoblanco.
Universidad Autónoma de Madrid.
28049, Madrid, Spain.

http://www.cnb.csic.es
http://www.biocomp.cnb.csic.es

+34 91 585 4510

"Las mejores almas son capaces de los mayores vicios como de las mayores
virtudes, y aquellos que caminan despacio por el camino recto pueden
llegar más lejos que los que corren pero se apartan de él." - Discurso
del Método, René Descartes.
Reply | Threaded
Open this post in threaded view
|

Re: Macro.getOptions();

ColinWhite
Thanks for the reply! I managed to solve my problem.

-Colin


________________________________
From: Juanjo Vega &lt;[hidden email]&gt;
To: [hidden email]
Sent: Friday, August 19, 2011 5:29 AM
Subject: Re: Macro.getOptions();

I pass arguments to my plugins from the command line using Macro.getOptions.

The way I do it is the following:

1) Create a macro to run plugin passing arguments to it:

macro &quot;MyMacro&quot; {
    run(&quot;My plugin&quot;, getArgument);
}


2) From my plugin, get and process arguments:

...
if (IJ.isMacro() &amp;&amp; Macro.getOptions() != null &amp;&amp; !Macro.getOptions().trim().isEmpty()) {
            processArgs(Macro.getOptions().trim());
}
...


3) Run plugin passing arguments to it:

java -Dplugins.dir=&lt;imagejpluginsdir&gt; -jar ij.jar -macro MyMacro.txt &quot;file1 file2 file3 ... fileN&quot;


It also works in the way IJ.run(&quot;My plugin&quot;,&quot;file1 file2 ...&quot;)
Maybe there is a better way to do that, but mine works.

Hope it helps.

Sincerely,

Juanjo.


On Aug 17, 2011, at 10:47 PM, ColinWhite wrote:

&gt; Hi,
&gt;
&gt; Could someone explain how the Macro.getOptions() and the Macro.setOptions()
&gt; commands work? I&#39;m doing this, but options always returns null.
&gt;
&gt; String options=Macro.getOptions();
&gt; Macro.setOptions(options);
&gt;
&gt; I&#39;m trying to get the user to input a file path in the arguments, such as:
&gt;
&gt; run(&quot;Analyzer&quot;, &quot;/Users/Colin/Desktop/Cell0024_img(Nisanth).txt&quot;);
&gt;
&gt; Thanks,
&gt; Colin
&gt;
&gt; --
&gt; View this message in context: http://imagej.588099.n2.nabble.com/Macro-getOptions-tp6697148p6697148.html
&gt; Sent from the ImageJ mailing list archive at Nabble.com.

------------------------------------------------------------
Juanjo Vega ([hidden email])

Unidad de Biocomputación. Laboratorio B-13.
Centro Nacional de Biotecnología. CNB-CSIC.
C&#92; Darwin, 3. Campus de Cantoblanco.
Universidad Autónoma de Madrid.
28049, Madrid, Spain.

http://www.cnb.csic.es
http://www.biocomp.cnb.csic.es

+34 91 585 4510

&quot;Las mejores almas son capaces de los mayores vicios como de las mayores
virtudes, y aquellos que caminan despacio por el camino recto pueden
llegar más lejos que los que corren pero se apartan de él.&quot; - Discurso
del Método, René Descartes.