<div dir="ltr"><div>Hi Curtis<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>There is already an unfortunate proliferation of run method 
signatures in ModuleService and CommandService, so I am honestly loath 
to add any more. But if you have an idea for a method to make the API 
more convenient, let us know!</div></blockquote>


<div><br></div>At this point I just wanted to make sure I wasn't missing any alternative APIs or conventions.  I can understand why you would not want to add more "run" methods.  <br><br></div><div>On first impression I could see a few things that would seemingly make the API more convenient for relatively simple scenarios (for example only one output, it is desired the command block until finished), but as you mention an extra 'get' is probably just as simple as an addition to the API.  <br>
</div><div><br></div>Thanks again for the information<br><div><br>Brian<br><div><div><div class="gmail_extra"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><br><div>There is already an unfortunate proliferation of run method signatures in ModuleService and CommandService, so I am honestly loath to add any more. But if you have an idea for a method to make the API more convenient, let us know!</div>



<div><br></div><br><br><div class="gmail_quote">

On Wed, Feb 19, 2014 at 11:22 AM, Brian Northan <span dir="ltr"><<a href="mailto:bnorthan@gmail.com" target="_blank">bnorthan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div dir="ltr"><div><div><div><div>Hi Curtis, Johannes and list<br><br></div><div>The scripting is working well.  <br></div><div><br></div><div>One quick question.  To run a command and retrieve the output I basically have this<br>






</div><div><br></div><div>--snip--<br></div><div># @CommandService command<br><br></div>module=command.run("somecommand").get();<br></div>output=module.getOutputs().get("output");<br><br></div><div>(or)<br>





output = module.getOutputs().values().toArray()[0];<br></div><div>--snap--<br><br></div><div>I'm wondering if there is a more concise way to run the command and get the output?? Something more like this....<br>
</div><div>
<br></div>output=command.run("somecommand");<br><br></div><div>Basically a way to run the command, have it automatically block, and return the output(s) (if they exist).  I could write a wrapper but first I want to make sure I know what all ready exists. <br>




</div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 18, 2014 at 4:14 PM, Brian Northan <span dir="ltr"><<a href="mailto:bnorthan@gmail.com" target="_blank">bnorthan@gmail.com</a>></span> wrote:<br>




<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>Thanks very much Johannes and Curtis<br><br></div>Johannes' code snippet works perfectly.  That's exactly what I needed to know.  How to access the services from a script.  Now that I know how to do that I can try some more complicated stuff (use the datasetservice and commandservice to open images and perform operations).  I will let you know if any questions come up.  Please let me know any additional information or tips that will be helpful. <br>





<br>Thanks again<span><font color="#888888"><br><br></font></span></div><span><font color="#888888">Brian<br></font></span></div><div><div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Feb 18, 2014 at 2:26 PM, Curtis Rueden <span dir="ltr"><<a href="mailto:ctrueden@wisc.edu" target="_blank">ctrueden@wisc.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p dir="ltr">Hi Brian,</p>
<p dir="ltr">I am out of the office today, and will reply in more detail later, but just wanted to quickly add: the example Johannes wrote should work with the current master branch as well as the recent 2.0.0-beta-7.7 release. Specifically, it will work if you "Run Script" since the parameter parsing mechanism etc. is all already in place. It just doesn't work from the Script Editor yet since that tool needs some TLC still. As Johannes says, I am still actively hacking on scripting support.</p>







<p dir="ltr">Also note that you can inject a Context parameter then make a new ImageJ gateway object wrapping it to easily access services the same way the tutorials do. (I forget whether ImageJ gateways are injectable ATM but if not, they will be.)</p>







<p dir="ltr">Anyway, please let us know if you are unable to run such scripts.</p>
<p dir="ltr">Regards,<br>
Curtis <br></p><div><div>
<div class="gmail_quote">On Feb 18, 2014 12:41 PM, "Johannes Schindelin" <<a href="mailto:Johannes.Schindelin@gmx.de" target="_blank">Johannes.Schindelin@gmx.de</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">






Hi Brian,<br>
<br>
On Tue, 18 Feb 2014, Brian Northan wrote:<br>
<br>
> Now I am trying to understand how one should be accessing ImageJ2<br>
> functionality from the scripts.  In ImageJ1 I use the static functions in<br>
> the IJ class, IJ.run, IJ.openImage etc.<br>
<br>
Yeah, in IJ2 you have to use a context. The static functions of ImageJ 1.x<br>
do not allow you to insulate separate processes from each other. That<br>
leads to surprising results, e.g. when you try to put more than one<br>
ImageJ 1.x applet into the same web page: it simply won't work, ever.<br>
<br>
> So far in ImageJ2 I have been writing java applications that start by<br>
> instantiating an ImageJ app and then use that to access services and run<br>
> commands. Basically following the tutorials.<br>
><br>
> So how are things intended to work in a script??  Is there a simpler api<br>
> somewhere like the IJ API??  Or does one still need to use the service APIs<br>
> in a script??<br>
<br>
This is a work in progress right now, under heavy construction.<br>
Eventually, something like this will work:<br>
<br>
-- snip --<br>
# @StatusService status<br>
# @OUTPUT String greeting<br>
<br>
status.showStatus(1, 2, "In progress...")<br>
status.warn("This is a gentle warning")<br>
status.showStatus(2, 2)<br>
<br>
greeting = "Hello, world!"<br>
-- snap --<br>
<br>
In other words, your input and output parameters will be specified using a<br>
syntax similar to ImageJ2 commands' at the top of the script.<br>
<br>
Ciao,<br>
Johannes<br>
</blockquote></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div><div><div>
</div></div></blockquote></div><br></div></div></div></div></div>