Login  Register

Using a function that returns a string in the str.*() functions fails

Posted by Stein Rørvik on Mar 08, 2021; 3:35pm
URL: http://imagej.273.s1.nabble.com/Using-a-function-that-returns-a-string-in-the-str-functions-fails-tp5024504.html

There seems to be a glitch in the macro parser when trying to use a function that returns a string as input in the str.*() functions:

The following fails:

run("Blobs (25K)");
if (getTitle().contains("blobs")) showMessage("this is the blobs image");

run("Blobs (25K)");
if (getTitle().endsWith("gif")) showMessage("this is a GIF image");


The following equivalent works:

run("Blobs (25K)");
imageTitle = getTitle();
if (imageTitle.contains("blobs")) showMessage("this is the blobs image");
if (imageTitle.endsWith("gif")) showMessage("this is a GIF image");


Another thing: It would be useful if it was mentioned in the macro functions documentation what version number these useful str.*() functions were introduced, so that one can insert the appropriate requires() statement before using them in a macro.


Stein

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html