The ImageJ macro language seems a bit inconsistent in the way it handles strings.
For example, if you try to round a string containing a number then you get an error:
Macro Error: Number or numeric function expected in line 1
However, if you try to round a string containing a number from “List.get()” you get the number back without an error, even though the result is still treated as a string:
newImage("Untitled", "32-bit black", 128, 128, 1); makeOval(32, 37, 61, 61); List.setMeasurements; print(List.get("BX")); //Returns 32.0 - acts like string print(round(List.get("BX"))); //Returns 32 - acts like Int print(round(List.get("BX")+1)); //Returns 33 - acts like Int print(List.get("BX")+1); //Returns 32.01 - acts like string
The macro language also does not throw an error if a string is compared to a string, or a string is compared to a number, for example according to ImageJ the following statements are true:
“apple” < “pear”
“32” < 6.4
32 > 6.4
Does anyone have any insights on why the macro language treats strings from List.get() differently, as well as how a string can be compared to a number, or one string can be greater in value than another?