I've read the help file pages on objects and arrays loads of times, but I'm still confused. There are examples of Sort, Push, Pop, Delete, RemoveAt, and so on, for 1D arrays or associative arrays, and then there are some complex examples with combinations of square brackets, curly braces, parentheses and/or dots, but little in between.
In writing the following code as a skeleton to try different things, I finally realised the simple assignment a[x] := temp adds a temp[] 1D array to a[].
The help on Push suggests a parameter can be passed with temp*, but again only in the context of a 1D array, so I'm guessing this can only be used for appending the contents of temp[] linearly to a 1D array.
Starter for you:
Code: Select all
#Warn
#NoEnv
a := [] ; a will be a 2D table
Loop, 3
{
x := A_Index
temp := [] ; create/clear temporary 1D array for 'y' dimension
Loop, 4
{
y:= A_Index
Random, r, 0, 9
temp.push(r)
; MsgBox % temp[y]
}
a[x] := temp ; This works. Just wondered if there's an equivalent push method
; like a[x].push(temp), which didn't work
; and any equivalent pop, delete, removeat, etc.
}
; Main question, is there a way to sort a[] on any chosen row/col?
; Output table
out := ""
Loop, 5
{
x := A_Index
Loop, 8
{
y:= A_Index
out .= a[x][y] . " "
}
out .= "`n"
}
MsgBox, % out