Login  Register

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

Posted by Wayne Rasband-2 on Mar 12, 2021; 6:46pm
URL: http://imagej.273.s1.nabble.com/Using-a-function-that-returns-a-string-in-the-str-functions-fails-tp5024504p5024530.html

> On Mar 8, 2021, at 10:35 AM, Stein Rørvik <[hidden email]> wrote:
>
> 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”);

This bug is fixed in the 1.53i29 daily build.

> 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.

I updated the documentation for the str.*() functions, under “String Functions” in the Macro Functions list, so it mentions the version of ImageJ required.

These string functions, where 's' is a string variable, are also available in ImageJ 1.52t and newer: s.charAt(i), s.contains(s2), s.endsWith(s2), s.indexOf(s2), s.lastIndexOf(s2), s.length, s.matches(s2), s.replace(s1,s2), s.startsWith(s2), s.substring(i1,i2), s.substring(i), s.toLowerCase, s.toUpperCase, s.trim.

-wayne

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