Login  Register

Re: string macro functions

Posted by Herbie on Nov 18, 2020; 8:16am
URL: http://imagej.273.s1.nabble.com/string-macro-functions-tp5024194p5024197.html

Greetings,

the macro

/////////////////
requires("1.53f")
ID="A09";
X=ID.charAt(0);
print(X);
X=ID.charAt(1);
print(X);
X=ID.charAt(2);
print(X);
/////////////////

nicely returns

A
0
9

Regards

Herbie

:::::::::::::::::::::::::::::::::::::::::::::
Am 18.11.20 um 03:09 schrieb Leoncio Vergara:

> Hi
>
> A very basic question: how do I use these string functions?
>
> These string functions, where 's' is a string variable, are also available: 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.
>
> they are mentioned in the built in macro functions list, but I couldn't figure to make them work. I get an error message.
>
> for example for  s.charAt(i), I tried the following:
>
> ID="A09";
> X=ID.charAt(1);
> print(X);
>
> thinking it would print "A" or "0"... but nope...
>
> Thanks for your help.
>
> Leo V.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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