I am trying to work with the new array notation. Here is a
simple script.

on mouseUp
  put fld "A" into A
  split A by return
  put A + 1 into B
  combine B using return
  put B into fld "B"
end mouseUp

In fld "A" I have the numbers 1 through 20. Upon combining
B, the results are returned in a seemingly random order. The
results are

2.000000
11.000000
12.000000
13.000000
14.000000
15.000000
16.000000
17.000000
18.000000
19.000000
20.000000
3.000000
21.000000
4.000000
5.000000
6.000000
7.000000
8.000000
9.000000
10.000000

I have some questions. First, how can I get the results in
the proper order? Using the sort command has not worked.
Secondly, how can I control the precision of calculations
using array math? Using       set number format to "0.##"
does not work. Third, how can math functions other than
addition and multiplication be done with arrays (other than,
"for each element in A"). For example, exponentiation,
taking logs, etc. (handy stuff in statistical analysis,
BTW).

Yes, I know. My third question can easily be handled with
element-by-element manipulation.

But I note that there is a difficulty with the new repeat
form. The repeat for each form goes from lowest to highest,
as in

put 0 into j
repeat for each line in A
add 1 to j
put a*2 into line j of B
end repeat

This will work because we can be assured that the repeat for
each form ascends numerically.

But in the case of an associative array, there is no
assurance of this ascension, particularly because keys(A) is
returned in such a strange order. Furthermore, not every
associative array will be indexed as A[1], A[2], etc...

So how do I follow the ascension characteristics of
something like this?

  repeat for each element i in A
    put a*2 into B[same key as A]
  end repeat

I am excited about the possibilities. But the trouble with
returning a split variable after combining is rather
daunting. Any help would be appreciated.

Thanks,

Raymond


Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to