Problem with arrays out function in msgbox Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
WBlois

Problem with arrays out function in msgbox  Topic is solved

11 Jun 2018, 18:34

Code: Select all

p:= A_Index
Msgbox % Array_%p%_1_1
It's code not operated outside func but inside func normally (it's work in func populated Array outside not work) :/
My variable Array is declared to Global in code start.

I need your help!!

Tks.
gregster
Posts: 9054
Joined: 30 Sep 2013, 06:48

Re: Problem with arrays out function in msgbox

11 Jun 2018, 20:36

More complete code would be better for illustrating your problem.
For example, the built-in variable A_index exists only in normal loops - like this, we cannot check what you might be doing wrong.

There are many ways to handle arrays and to use them in functions. Two examples with linear arrays:

Code: Select all

arr := [1,3,5,7,9,11,13,15]
testfunc(arr)

global arr2:= [1,2,3,4,6]
testfunc2()
ExitApp
;---------------------------
testfunc(array){
	loop % array.length()
		msgbox % array[A_index]
	for key, value in array
		msgbox % "Key: " key "  Value: " value
}
;---------------
testfunc2(){
	loop % arr2.length()
		msgbox % arr2[A_index]
	for key, value in arr2
		msgbox % "Key: " key "  Value: " value
}
Edited

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 381 guests