Macro problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Macro problem

Girault France
Dear all,

I'm quite new in ImageJ and I desperately try to write a macro...
I have a file called initialisation in which I have several tasks written.
One of those has a variable that I would like to change when I call the file in the macro recorder on IJ without opening the source code to modify the value of the variable.
But Idon't know how to do.
I've tried several possibilities,
 
For instance :
--> file called initialisation)
MAN_ON = "50015"; //
run("serial plugin", "genericcmd=" + MAN_ON);
function setting (lampSet1) {
POS_ABS_LAMP = "11141"; // Set lamp to specified absolute value (0 - 1275, 0 - 12V)
 
run("serial plugin", "genericcmd=" + POS_ABS_LAMP + lampSet1);
}
setting (1000);
 

(--> macro recorder)
run("initialisation", "setting (500)");

all the tasks seem to work, exept the one with the new defined value.
 
Does anyone know how to do?
Many thanks,
france
 
 
Reply | Threaded
Open this post in threaded view
|

Antwort: Macro problem

Joachim Wesner
Hi France,

I think I understand what you try to achieve, but I don´t really see where
it´s done in your code. I assume you have one or more functions that use
that modified value/variable and one function that sets that variable.
Which one is the latter? Is it setting(lampset1)? So where is the argument
of setting reused in other functions?

You need to put all macros that share that value in a "macro set", you need
to store that variable value in a global variable defined with "var".

From the Macro language doc:

----------------------------------------------------------------------------------------------------------------------------------------------

Macros in a macro set can communicate with each other using global
variables.
          var s = "a string";

          macro "Enter String..." {
              s = getString("Enter a String:", s);
          }

          macro "Print String" {
              print("This is Macro 2");
          }

      ...................

Global variables should be declared before the macros that use them using
the 'var' statement. For example:
          var x=1;

          macro "Macro1..." {
              x = getNumber("x:", x);
          }

          macro "Macro2" {
              print("x="+x);
          }


      Joachim



                                                                                                                                         
                      Girault France                                                                                                    
                      <france.girault@ER         An:      [hidden email]                                                            
                      DW.ETHZ.CH>                Kopie:                                                                                  
                      Gesendet von:              Thema:   Macro problem                                                                  
                      ImageJ Interest                                                                                                    
                      Group                                                                                                              
                      <[hidden email]                                                                                                
                      OV>                                                                                                                
                                                                                                                                         
                                                                                                                                         
                      17.06.2006 12:58                                                                                                  
                      Bitte antworten an                                                                                                
                      ImageJ Interest                                                                                                    
                      Group                                                                                                              
                                                                                                                                         




Dear all,

I'm quite new in ImageJ and I desperately try to write a macro...
I have a file called initialisation in which I have several tasks written.
One of those has a variable that I would like to change when I call the
file in the macro recorder on IJ without opening the source code to modify
the value of the variable.
But Idon't know how to do.
I've tried several possibilities,

For instance :
--> file called initialisation)
MAN_ON = "50015"; //
run("serial plugin", "genericcmd=" + MAN_ON);
function setting (lampSet1) {
POS_ABS_LAMP = "11141"; // Set lamp to specified absolute value (0 - 1275,
0 - 12V)

run("serial plugin", "genericcmd=" + POS_ABS_LAMP + lampSet1);
}
setting (1000);


(--> macro recorder)
run("initialisation", "setting (500)");

all the tasks seem to work, exept the one with the new defined value.

Does anyone know how to do?
Many thanks,
france





______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________