giacmosuaviet189

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
giacmosuaviet189
Posts: 1
Joined: 21 Sep 2018, 22:39
Contact:

giacmosuaviet189

21 Sep 2018, 22:43

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:
User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: giacmosuaviet189

26 Sep 2018, 14:24

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
			}
		}
	}
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], mikeyww, Oblomov228, PsysimSV, uchihito and 195 guests