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 |
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. |
Thanks for the reply! I managed to solve my problem.
-Colin ________________________________ From: Juanjo Vega <[hidden email]> 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 "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. |
Free forum by Nabble | Edit this page |