Login  Register

Re: User input for a global variable in a macro?

Posted by Cammer, Michael on Jan 24, 2014; 6:23pm
URL: http://imagej.273.s1.nabble.com/User-input-for-a-global-variable-in-a-macro-tp3694344p5006269.html

Try this.  It should work until the macros are reinstalled at which time they will be reset to the initial values.

// defined as globals at the very beginning

var a = 2;
var b = 10;
var c = 2;
var d = 10;

macro "Test globals" {

  Dialog.create("Intensity values");
  Dialog.addNumber("C1min:", a);
  Dialog.addNumber("C1max:", b);
  Dialog.addNumber("C2min:", c);
  Dialog.addNumber("C2max:", d);
  Dialog.show();

  a = Dialog.getNumber();
  b = Dialog.getNumber();
  c = Dialog.getNumber();
  d = Dialog.getNumber();

  print(a,b,c,d);
} // end macro

===========================================================================
Michael Cammer, Microscopy Core & Dustin Lab , Skirball Institute, NYU Langone Medical Center
Cell:  914-309-3270   Lab: 212-263-3208
http://ocs.med.nyu.edu/microscopy & http://www.med.nyu.edu/skirball-lab/dustinlab/


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of mmettlen
Sent: Friday, January 24, 2014 12:23 PM
To: [hidden email]
Subject: Re: User input for a global variable in a macro?

Related to this, I have a macro using:

Dialog.create("Intensity values");
Dialog.addNumber("C1min:", 2);
Dialog.addNumber("C1max:", 10);
Dialog.addNumber("C2min:", 2);
Dialog.addNumber("C2max:", 10);
...
Dialog.show();

a = Dialog.getNumber();
b = Dialog.getNumber();
c = Dialog.getNumber();
d = Dialog.getNumber();
....

As shown, each time I run the macro, the default values '2' and '10' are shown in the dialog box. Is there any way that the macro, when it runs the next time, replaces/recalls these values with the last user input (i.e. a, b, c, d, ....)?

Thx, Marcel



------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================

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