Login  Register

Re: Issue on newArray macro function

Posted by CARL Philippe (LBP) on Jan 17, 2018; 10:09am
URL: http://imagej.273.s1.nabble.com/Issue-on-newArray-macro-function-tp5019886p5019898.html

Dear all,
Since my previous posting seems to have launched a discussion, I would have another modification to submit.
Indeed, the Array.fill(array, value) macro code up to today only works for numeric values.
Thus why not simply replace the following lines:
        double v = getLastArg();
                for (int i=0; i<a.length; i++)
                    a[i].setValue(v);
in the "Variable[] fillArray()" method of the "ij.macro. Functions.java" file by:
        Variable v = getLastArg();
        Arrays.fill(a, v);
Which would then as well extend this method for strings using the following java method:
https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#fill%28char%5B%5D,%20char%29
My best regards,
Philippe

-----Message d'origine-----
De : ImageJ Interest Group [mailto:[hidden email]] De la part de Jan Eglinger
Envoyé : mercredi 17 janvier 2018 09:30
À : [hidden email]
Objet : Re: Issue on newArray macro function

Hi Wayne,

On 16.01.2018 21:20, Wayne Rasband wrote:
> Your proposed fix for this bug is in the latest daily build (1.51u12).

This bug is not limited to expressions with +,-,* or /

For example, while the following works:

     a = newArray(2, acos(0.2), log(2));

these other lines throw exceptions:

     a = newArray(acos(0.2), log(2), 2);
     a = newArray(log(2), 2, acos(0.2));

Jan



>
>> Which means that is there is something else than "," after the first
>> element it interprets the code as being a newArray(size).
>>
>> I guess the fix for this issue would be to replace the line
>>
>> if (next==STRING_CONSTANT || nextNext==','
>>
>>         || nextNext=='[' || next=='-' || next==PI)
>>
>>             return initNewArray();
>>
>> With
>>
>> if (next==STRING_CONSTANT || nextNext==',' || next==PI
>>
>>         || nextNext=='[' || next=='+' || next=='-' || next=='*' ||
>> next=='/')
>>
>>             return initNewArray();
>>
>> Within the "Variable[] newArray" method in the " ij.macro. Functions.java"
>> file.
>>
>> My best regards,
>>
>> Philippe
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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

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