Hi,
Since updating Fiji/ImageJ last week (I guess it's the 1.51u update) my macros are failing when trying to assign a value into an array. I could isolate the problem using this macro: macro "test" { nameArray = newArray("abcd.tif", "efgh.tif"); print("lenght of nameArray: "+ nameArray.length); extArray = newArray(nameArray.length); print("lenght of extArray: "+ extArray.length); } which prints: lenght of nameArray: 2 lenght of extArray: 1 Why is extArray not the same length as nameArray? This is what is causing the error when I subsequently try to assign a value to extArray[1]. I am positive that newArray(otherArray.length) used to work as I am using it a lot in my macros. What happens here? Thank you for your help, Christophe -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Christophe,
I must say that this behaves as I would expect. macro "test" { nameArray = newArray("abcd.tif", "efgh.tif"); print("lenght of nameArray: "+ nameArray.length); extArray = newArray(nameArray.length); print("lenght of extArray: "+ extArray.length); print(extArray[0]) } Prints: lenght of nameArray: 2 lenght of extArray: 1 2 As extArrray has only one value, being 2 But you are correct, an older version of Fiji gives, lenght of nameArray: 2 lenght of extArray: 2 0 Also extArray[1] give as value 0 Best wishes Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility Centre for Core Biotechnology Services University of Leicester www.le.ac.uk/advanced-imaging-facility -----Original Message----- From: Christophe Leterrier [mailto:[hidden email]] Sent: 19 February 2018 10:50 To: [hidden email] Subject: Strange bug using array.length in latest ImageJ Hi, Since updating Fiji/ImageJ last week (I guess it's the 1.51u update) my macros are failing when trying to assign a value into an array. I could isolate the problem using this macro: macro "test" { nameArray = newArray("abcd.tif", "efgh.tif"); print("lenght of nameArray: "+ nameArray.length); extArray = newArray(nameArray.length); print("lenght of extArray: "+ extArray.length); } which prints: lenght of nameArray: 2 lenght of extArray: 1 Why is extArray not the same length as nameArray? This is what is causing the error when I subsequently try to assign a value to extArray[1]. I am positive that newArray(otherArray.length) used to work as I am using it a lot in my macros. What happens here? Thank you for your help, Christophe -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Christophe and Kees.
This was fixed in 1.51v1. see : https://github.com/imagej/imagej1/commit/78678b31514ba2c8f193ea8746bbe0eeeacbce1a Jerome 2018-02-19 13:12 GMT+01:00 Straatman, Kees (Dr.) <[hidden email]>: > Dear Christophe, > > I must say that this behaves as I would expect. > > macro "test" { > nameArray = newArray("abcd.tif", "efgh.tif"); > print("lenght of nameArray: "+ nameArray.length); > extArray = newArray(nameArray.length); > print("lenght of extArray: "+ extArray.length); > print(extArray[0]) > } > > Prints: > > lenght of nameArray: 2 > lenght of extArray: 1 > 2 > > As extArrray has only one value, being 2 > > But you are correct, an older version of Fiji gives, > > lenght of nameArray: 2 > lenght of extArray: 2 > 0 > > Also extArray[1] give as value 0 > > Best wishes > > Kees > > > Dr Ir K.R. Straatman > Senior Experimental Officer > Advanced Imaging Facility > Centre for Core Biotechnology Services > University of Leicester > www.le.ac.uk/advanced-imaging-facility > > > > -----Original Message----- > From: Christophe Leterrier [mailto:[hidden email]] > Sent: 19 February 2018 10:50 > To: [hidden email] > Subject: Strange bug using array.length in latest ImageJ > > Hi, > > Since updating Fiji/ImageJ last week (I guess it's the 1.51u update) my > macros are failing when trying to assign a value into an array. I could > isolate the problem using this macro: > > macro "test" { > nameArray = newArray("abcd.tif", "efgh.tif"); print("lenght of nameArray: > "+ nameArray.length); extArray = newArray(nameArray.length); print("lenght > of extArray: "+ extArray.length); } > > which prints: > > lenght of nameArray: 2 > lenght of extArray: 1 > > Why is extArray not the same length as nameArray? This is what is causing > the error when I subsequently try to assign a value to extArray[1]. I am > positive that newArray(otherArray.length) used to work as I am using it a > lot in my macros. What happens here? > > Thank you for your help, > > Christophe > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- Jerome Mutterer CNRS - Institut de biologie moléculaire des plantes 12, rue du Général Zimmer 67084 Strasbourg Cedex www.ibmp.cnrs.fr -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |