Get help with using AutoHotkey and its commands and hotkeys
Posts: 1
Joined: 21 Sep 2018, 22:39
GitHub: giacmosuaviet189


Post by giacmosuaviet189 » 21 Sep 2018, 22:43

Hey, I had a thread going on the old forum: ... /?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
Posts: 1092
Joined: 19 Dec 2013, 11:16
Location: USA

Re: giacmosuaviet189

Post by TheDewd » 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
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
Post Reply

Return to “Ask For Help”