Login  Register

global var in macro

Posted by Aryeh Weiss on Jan 14, 2009; 10:55am
URL: http://imagej.273.s1.nabble.com/Reslice-stack-at-various-angles-tp3694050p3694052.html

We are having a problem with using global variables in macros. A var declaration
at the beginning of the macro file seems to cause everything to hang.

For example, here is a small macro copied from a previous posting on the subject:

//================

var x;

macro "test" {
    x=10;
    f();
    print (x);
    exit("Terminating normally...");
}

function f(){
      x = 20;
}

//=================

If I omit var x; declaration, then it runs fine (but of course it prints
that x is 10, as expected).

If I include the var x; declaration, then it hangs. I ran it with the debugger
and single step. It advances past the var declaration and highlights the
macro "test" { line. There it stops (ie, cntl-E will not advance operation to
the next line).

It seems something obvious that I missed. I did not find this problem in the
archives.

--aryeh
--
Aryeh Weiss
School of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384050