How do you access global variables in a macro?

imagej

#1

I would like to access the length of a line. This value shows up in the status bar when the line is moved, so there must be a live variable for it. The variable name is obviously not “length”, or the code below would work.

newImage(“Untitled”, “RGB white”, 660, 510, 1);
makeLine(50,50,100,100);
print(“length=”+length);

is there a list of global variables that are live during a session, and how are they accessed within a macro?

Thanks
Ron DeSpain


#2

Have a look at the ImageJ macro API, e.g., getLine:

https://imagej.nih.gov/ij/developer/macro/functions.html#G

Example:

https://imagej.nih.gov/ij/macros/GetLineDemo.txt