In AutoHotkey, arrays are mostly conceptual: Each array is really just a collection of sequentially numbered variables, with each variable being perceived as an element of the array. AutoHotkey does not link these variables together in any way.
In addition to array-creating commands like StringSplit and "WinGet List", any command that accepts an OutputVar or that assigns a value to a variable can be used to create an array. The simplest example is the assignment operator (:=), as shown below:
Array%j% := A_LoopField
Multidimensional arrays are possible by using a separator character of your choice between the indices. For example:
Array%j%_%k% := A_LoopReadLine
The following example demonstrates how to create and access an array, in this case a series of names retrieved from a text file:
; Write to the array: ArrayCount = 0 Loop, Read, C:\Guest List.txt ; This loop retrieves each line from the file, one at a time. { ArrayCount += 1 ; Keep track of how many items are in the array. Array%ArrayCount% := A_LoopReadLine ; Store this line in the next array element. } ; Read from the array: Loop %ArrayCount% { ; The following line uses the := operator to retrieve an array element: element := Array%A_Index% ; A_Index is a built-in variable. ; Alternatively, you could use the "% " prefix to make MsgBox or some other command expression-capable: MsgBox % "Element number " . A_Index . " is " . Array%A_Index% }
On a related note, NumPut() and NumGet() can be used to store/retrieve a collection of numbers in binary format. This might be helpful in cases where performance and/or memory conservation are important.
"Scripting.Dictionary" is an operating system feature that has more capabilities and flexibility than AutoHotkey's pseudo-arrays. Its use is demonstrated at www.autohotkey.com/forum/topic17838.html.