Retrieving value from IJ.runMacro()
Posted by Potterd2 on
URL: http://imagej.273.s1.nabble.com/Retrieving-value-from-IJ-runMacro-tp5018046.html
Hello folks,
Currently I am working on a plugin for ImageJ but I've gotten a bit stuck. I want to get the value of height and width of the currently selected window but I'm having some problems. Currently what my code looks like is this:
String s2_strWidth = null;
String s2_strHeight = null;
int s2_width = 0;
int s2_height = 0;
s2_strWidth = IJ.runMacro("getWidth();");
if(s2_strWidth != null) {
s2_width = Integer.valueOf(s2_strWidth);
IJ.log("Wait what's going on");
}
else {
IJ.log("You are throwing an exception at s2_strWidth");
return;
}
s2_strHeight = IJ.runMacro("getHeight();");
if(s2_strHeight != null) {
s2_height = Integer.valueOf(s2_strHeight);
IJ.log("Wait what's going on");
}
else {
IJ.log("You are throwing an exception at getHeight");
return;
}
However, s2_strWidth and s2_strHeight are always returning null so I cannot physically get the value right now. I'm sure that I am missing something here that I need to get the values that I need. Can someone see what I am missing? Or is there a better way of trying to use IJ.runMacro ?