Re: ImageJ macro language - return statement
Posted by
Rasband, Wayne (NIH/NIMH) [E] on
May 21, 2014; 12:11am
URL: http://imagej.273.s1.nabble.com/ImageJ-macro-language-return-statement-tp5007801p5007816.html
On May 20, 2014, at 3:57 AM, Niko Ehrenfeuchter wrote:
> Dear all,
>
> I'm a bit puzzled by the behaviour of the macro language "return" statement, i.e. running the following code
>
>> function foo1(mystr){
>> return(mystr);
>> }
>>
>> function foo2(mystr){
>> return mystr;
>> }
>>
>> print(foo1("some random text"));
>> print(foo2("some random text"));
>
> results in this output:
>
>> 0
>> some random text
>
> Is this intended? I couldn't find any hint about this in the official macro language documentation [1].
The return statement in the macro language looks like this:
return expression;
The expression is optional and is assumed to be numeric if it starts with "(". Expressions in assignment statements are also assumed to be numeric if they start with "(". For example
s = ("abc"+"def");
print(s);
outputs 0.
-wayne
> Cheers
> ~Niko
>
> [1]
http://rsbweb.nih.gov/ij/developer/macro/macros.html#functions--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html