Re: In a macro, how can I index upon an array whose name and length are passed to a function?
Posted by Gabriel Landini on Jan 29, 2009; 8:39pm
URL: http://imagej.273.s1.nabble.com/In-a-macro-how-can-I-index-upon-an-array-whose-name-and-length-are-passed-to-a-function-tp3693895p3693897.html
On Thursday 29 January 2009 20:07:36 Bill Christens-Barry wrote:
> In a macro, how can I index upon an array whose name and length are passed
> to a function? This nonworking example shows what I'd like to do:
Maybe this is what you want:
a = newArray(1, 2, 3);
b = newArray(4, 5, 6, 7);
sumTheArray(a);
sumTheArray(b);
function sumTheArray(aname) {
theArraySum = 0;
for (i = 0; i < aname.length; i++) {
theArraySum += aname[i];
}
print(theArraySum);
}
Cheers
G.