Hi Bill,
Try this:
-----
a = newArray(1, 2, 3);
b = newArray(4, 5, 6, 7);
sumTheArray(a);
sumTheArray(b);
function sumTheArray(arrayName) {
theArraySum = 0;
for (i = 0; i < lengthOf(arrayName); i++) {
theArraySum = theArraySum + arrayName[i];
}
print(theArraySum);
}
-----
-Curtis
On Thu, Jan 29, 2009 at 2:07 PM, Bill Christens-Barry <
[hidden email]> 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:
>
> a = newArray(1, 2, 3);
> b = newArray(4, 5, 6, 7);
>
> sumTheArray("a", 3);
> sumTheArray("b", 4);
>
> function sumTheArray(arrayName, n) {
> theArraySum = 0;
> for (i = 0, i < n; i++) {
> theArraySum += arrayName[n];
> print(theArraySum);
> }
> }
>
> Bill Christens-Barry
>