Login  Register

Re: getArgument() equivalent for installed macros?

Posted by Bill Christens-Barry-2 on Jan 18, 2017; 7:54pm
URL: http://imagej.273.s1.nabble.com/getArgument-equivalent-for-installed-macros-tp5017917p5017922.html

Gabriel,

Thanks for your suggestion that I try putting the called macro into the plugins folder so it would be automatically loaded. Unfortunately, this didn't give the hoped for result when I tried a test macro "Test_Macro" that simply prints the passed argument after using getArgument():

    macro "Test_macro" {
        theArg = getArgument();
        print("Test_macro actually ran and printed", theArg);
    }

After installing "Test_macro" into the plugins menu, I ran the following macro code from its text window:

    run("Test macro", "theArgString");
    runMacro("Test_macro", "theArgString");

        ==>

    Test_macro actually ran and printed
    Test_macro actually ran and printed theArgString

Note that the successful second command runs the macro from a file, while the unsuccessful first command line uses the installed version. It appears that run() can't suitably pass the optional second argument, while runMacro() can. It's important to me to have the called macro preloaded and that the caller not be loaded, which is why I'm not using a global variable.

Bill Christens-Barry

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