According to the IJ doc
http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html showImageWithCancel("message") should return "false" if CANCEL is clicked and otherwise "true". But in ImageJ 1.43o I get the error "number or numeric function expected" for: if(!showMessageWithCancel("Is this OK?")) showMessage("You clicked CANCEL"); I want to branch to alternative actions according to "OK" or "CANCEL". So far as I can see showMessageWithCancel() acts just like showMessage() except that it has a CANCEL button that simply exits the routine :-( Alan ______________________________________________ Dr Alan Hewat, NeutronOptics, Grenoble, FRANCE <[hidden email]> +33.476.98.41.68 http://www.NeutronOptics.com/hewat ______________________________________________ |
Hi Alan,
at least in the current version of ImageJ, IJ.showMessageWithCancel should have two arguments: public static boolean showMessageWithCancel(String title, String msg) Michael ________________________________________________________________ On 3 Feb 2010, at 18:21, Alan Hewat wrote: > According to the IJ doc > http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html > showImageWithCancel("message") should return "false" if CANCEL is > clicked and otherwise "true". > > But in ImageJ 1.43o I get the error "number or numeric function > expected" for: > > if(!showMessageWithCancel("Is this OK?")) showMessage("You clicked > CANCEL"); > > I want to branch to alternative actions according to "OK" or "CANCEL". > So far as I can see showMessageWithCancel() acts just like > showMessage() except that it has a CANCEL button that simply exits the > routine :-( > > Alan > ______________________________________________ > Dr Alan Hewat, NeutronOptics, Grenoble, FRANCE > <[hidden email]> +33.476.98.41.68 > http://www.NeutronOptics.com/hewat > ______________________________________________ |
Thanks Michael, but I understand the "title" string is optional in
both showMessageWithCancel(); and showMessage(); and I checked that including the title makes no difference. Am I missing something fundamental here in that I should include some IJ extension package perhaps ? Alan. On 3 February 2010 18:37, Michael Schmid <[hidden email]> wrote: > Hi Alan, > > at least in the current version of ImageJ, IJ.showMessageWithCancel should > have two arguments: > public static boolean showMessageWithCancel(String title, String msg) > > > Michael > ________________________________________________________________ > > On 3 Feb 2010, at 18:21, Alan Hewat wrote: > >> According to the IJ doc >> http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html >> showImageWithCancel("message") should return "false" if CANCEL is >> clicked and otherwise "true". >> >> But in ImageJ 1.43o I get the error "number or numeric function expected" >> for: >> >> if(!showMessageWithCancel("Is this OK?")) showMessage("You clicked >> CANCEL"); >> >> I want to branch to alternative actions according to "OK" or "CANCEL". >> So far as I can see showMessageWithCancel() acts just like >> showMessage() except that it has a CANCEL button that simply exits the >> routine :-( >> >> Alan Dr Alan Hewat, NeutronOptics, Grenoble, FRANCE <[hidden email]> +33.476.98.41.68 http://www.NeutronOptics.com/hewat ______________________________________________ |
In reply to this post by Alan Hewat
On Feb 3, 2010, at 12:21 PM, Alan Hewat wrote:
> According to the IJ doc > http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html > showImageWithCancel("message") should return "false" if > CANCEL is clicked and otherwise "true". > > But in ImageJ 1.43o I get the error "number or numeric function expected" for: > > if(!showMessageWithCancel("Is this OK?")) showMessage("You clicked CANCEL"); > > I want to branch to alternative actions according to "OK" or "CANCEL". > So far as I can see showMessageWithCancel() acts just like > showMessage() except that it has a CANCEL button that simply > exits the routine :-( The API docs at http://rsbweb.nih.gov/ij/developer/api/ij/IJ.html are for plugin and JavaScript writers. Macro writers should be looking at the descriptions of the built in macro functions at http://rsbweb.nih.gov/ij/developer/macro/functions.html Here is the description of the showMessageWithCancel() function: showMessageWithCancel(["title",]"message") Displays "message" in a dialog box with "OK" and "Cancel" buttons. "Title" (optional) is the dialog box title. The macro exits if the user clicks "Cancel" button. It won't work because it causes the macro to exit when the user clicks "Cancel". What you want is the getBoolean() macro function: getBoolean("message") Displays a dialog box containing the specified message and "Yes", "No" and "Cancel" buttons. Returns true (1) if the user clicks "Yes", returns false (0) if the user clicks "No" and exits the macro if the user clicks "Cancel". Here is an example: if (!getBoolean("Is this OK?")) showMessage("The user clicked 'No'"); -wayne |
Free forum by Nabble | Edit this page |