Hello everyone,
To start with, I'm new in the world of macros so excuse me if the question is trivial ! In a first macro, I determined the center of an object with 2 variables X0, Y0 and I want to re-use these two coordinates in a second macro, which will be run separately. I took a look at some discussions, espcially the following one : http://imagej.1557.x6.nabble.com/User-input-for-a-global-variable-in-a-macro-td3694344.html but it seems to be a little bit different from what I'm looking for. How to do that? Thanks ! Julien -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Probably a better way but I output to results table to retrieve later or to
a text file. Best On Tue, 21 May 2019, 16:05 julien.jurczak, <[hidden email]> wrote: > Hello everyone, > > To start with, I'm new in the world of macros so excuse me if the question > is trivial ! > > In a first macro, I determined the center of an object with 2 variables X0, > Y0 and I want to re-use these two coordinates in a second macro, which will > be run separately. > > I took a look at some discussions, espcially the following one : > > http://imagej.1557.x6.nabble.com/User-input-for-a-global-variable-in-a-macro-td3694344.html > but it seems to be a little bit different from what I'm looking for. > > How to do that? > Thanks ! > Julien > > > > > -- > Sent from: http://imagej.1557.x6.nabble.com/ > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Mikeo
Dear Julien,
Below is an example in which one macro passes variables to the second macro. This is assuming that you want the first macro to call the second. The second macro needs to be located in the macros directory or include the full file path to the macro. See the "runMacro" documentation here. https://imagej.nih.gov/ij/developer/macro/functions.html The getArgument command in the second macro is the other command you need. Most of the second macro in this example is simply parsing the passed argument for the values converted to a string and passed from the first macro. Best, George macro "testMacro1"{ x0=1.5; y0=2.7; argToPass=toString(x0+"_"+y0); runMacro("testMacro2",argToPass); } macro "testMacro2"{ passedArg=getArgument(); indexOfSeparator=indexOf(passedArg,"_"); x0=parseFloat(substring(passedArg,0,indexOfSeparator)); y0=parseFloat(substring(passedArg,indexOfSeparator+1)); print("x0="+x0); print("y0="+y0); sum=x0+y0; print(sum); } On Tue, May 21, 2019 at 11:03 AM julien.jurczak <[hidden email]> wrote: > Hello everyone, > > To start with, I'm new in the world of macros so excuse me if the question > is trivial ! > > In a first macro, I determined the center of an object with 2 variables X0, > Y0 and I want to re-use these two coordinates in a second macro, which will > be run separately. > > I took a look at some discussions, espcially the following one : > > http://imagej.1557.x6.nabble.com/User-input-for-a-global-variable-in-a-macro-td3694344.html > but it seems to be a little bit different from what I'm looking for. > > How to do that? > Thanks ! > Julien > > > > > -- > Sent from: http://imagej.1557.x6.nabble.com/ > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
I'm not a macro hacker, but...isn't this a good application for an ROI?
-- Kenneth Sloan [hidden email] Vision is the art of seeing what is invisible to others. > On May 22, 2019, at 13:40, George Patterson <[hidden email]> wrote: > > Dear Julien, > Below is an example in which one macro passes variables to the second > macro. This is assuming that you want the first macro to call the second. > The second macro needs to be located in the macros directory or include the > full file path to the macro. > See the "runMacro" documentation here. > https://imagej.nih.gov/ij/developer/macro/functions.html > The getArgument command in the second macro is the other command you need. > Most of the second macro in this example is simply parsing the passed > argument for the values converted to a string and passed from the first > macro. > Best, > George > > macro "testMacro1"{ > x0=1.5; > y0=2.7; > argToPass=toString(x0+"_"+y0); > runMacro("testMacro2",argToPass); > } > > macro "testMacro2"{ > passedArg=getArgument(); > indexOfSeparator=indexOf(passedArg,"_"); > x0=parseFloat(substring(passedArg,0,indexOfSeparator)); > y0=parseFloat(substring(passedArg,indexOfSeparator+1)); > print("x0="+x0); > print("y0="+y0); > sum=x0+y0; > print(sum); > } > > > > > > > > On Tue, May 21, 2019 at 11:03 AM julien.jurczak <[hidden email]> > wrote: > >> Hello everyone, >> >> To start with, I'm new in the world of macros so excuse me if the question >> is trivial ! >> >> In a first macro, I determined the center of an object with 2 variables X0, >> Y0 and I want to re-use these two coordinates in a second macro, which will >> be run separately. >> >> I took a look at some discussions, espcially the following one : >> >> http://imagej.1557.x6.nabble.com/User-input-for-a-global-variable-in-a-macro-td3694344.html >> but it seems to be a little bit different from what I'm looking for. >> >> How to do that? >> Thanks ! >> Julien >> >> >> >> >> -- >> Sent from: http://imagej.1557.x6.nabble.com/ >> >> -- >> 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 |
Free forum by Nabble | Edit this page |