how to I can add array parameter ? Topic is solved

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
gameba
Posts: 18
Joined: 20 Mar 2018, 12:24

how to I can add array parameter ?

21 Jun 2018, 05:31

Hi, guys
Pls, help how to I can add array parameter ? I try below code but it isn't work
p/s I use AHK_H v1 64bit

Code: Select all

array:=[1,2,3,4]
threads:=[]
Loop 3
threads[A_Index]:=AhkThread("
(
	var:=A_Args[1]
	msgbox % var[1]
	Return

)", array)

ESC::
ExitApp
if the array are not allow,so How do I assign array from main code into a thread?

Thanks!
HotKeyIt
Posts: 1705
Joined: 29 Sep 2013, 18:35
Contact:

Re: how to I can add array parameter ?  Topic is solved

21 Jun 2018, 14:30

You can pass the parameters as usual ..., 1 2 3 4, just make sure it is a string!
You can also pass an object reference and use the object itself:

Code: Select all

array:=[1,2,3,4]
threads:=[]
Loop 3
threads[A_Index]:=AhkThread("
(
	var:=Object(A_Args[1])
	msgbox % var[" A_Index "]
	Return

)", (&array) "")

ESC::
ExitApp
If multiple threads need to access the object use CriticalObject instead!
gameba
Posts: 18
Joined: 20 Mar 2018, 12:24

Re: how to I can add array parameter ?

21 Jun 2018, 19:45

@HotKeyIt awesome. Thank you very much! :D
HotKeyIt
Posts: 1705
Joined: 29 Sep 2013, 18:35
Contact:

Re: how to I can add array parameter ?

22 Jun 2018, 07:36

Forgot to mention, you can also use named parameters in v2:

Code: Select all

thread:=AhkThread("
(
	msgbox A_Args.name "``n" A_Args.version
	Return

)", "name ahk version 1")

ESC::
ExitApp

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 3 guests