Hey, I had a thread going on the old forum: http://www.autohotkey.com/board/topic/9 ... /?p=616421
Basically, I'm trying to get the hang of arrays and was wondering Is it possible to call an associative array by it's row and column numbers rather than the key? So basically an associative array that you can call by either the key or a numeric row, column location?
Thanks for your time reading and considering this.
Here's my testing code I've been developing to learn about arrays:
giacmosuaviet189
-
- Posts: 1
- Joined: 21 Sep 2018, 22:39
- Contact:
Re: giacmosuaviet189
Is this what you want?
Code: Select all
#SingleInstance, Force
MyArray := {KeyA: "ValueA", KeyB: "ValueB", KeyC: "ValueC", KeyD: "ValueD", KeyE: "ValueE"}
MsgBox, % MyArrayFunction(MyArray, 3, false) ; Return value by number
MsgBox, % MyArrayFunction(MyArray, "KeyE") ; Return value by key
MyArrayFunction(ArrayName, KeyOrNumber, IsKey := 1) {
For Key, Value In ArrayName {
If (IsKey = 0) {
If (A_Index = KeyOrNumber) {
return Value
}
} Else If (IsKey = 1) {
If (Key = KeyOrNumber) {
return Value
}
}
}
}
Who is online
Users browsing this forum: Google [Bot], mikeyww, Oblomov228, PsysimSV, uchihito and 195 guests