Page 1 of 1

BoundFunc Cannot Be Used Directly As Function Parameter?

Posted: 20 Oct 2017, 09:38
by egocarib
I couldn't find anything in the docs about this.

This works as expected:

Code: Select all

fn := Func("FnA").Bind(0)
Hotkey("NumpadAdd", fn)
Return

FnA(num := 0)
{
	MsgBox(num)
}
This throws an error (the error varies between v1 and v2, but it's present in every version I tested)

Code: Select all

Hotkey("NumpadAdd", Func("FnA").Bind(0))
Return

FnA(num := 0)
{
	MsgBox(num)
}

Re: BoundFunc Cannot Be Used Directly As Function Parameter?

Posted: 20 Oct 2017, 10:19
by Helgef
Hotkey - label wrote:If not a valid label name, this parameter can be the name of a function, or a single variable reference containing a function object. For example, Hotkey(funcobj, "On"). Other expressions which return objects are currently unsupported.
(my bold)
source

Re: BoundFunc Cannot Be Used Directly As Function Parameter?

Posted: 20 Oct 2017, 10:33
by egocarib
Ah, I missed that detail. :think: Thanks, Helgef.

Re: BoundFunc Cannot Be Used Directly As Function Parameter?

Posted: 20 Oct 2017, 11:39
by Helgef
Np, for your reference, settimer has the same limitation.

Cheers.

Re: BoundFunc Cannot Be Used Directly As Function Parameter?

Posted: 01 Jan 2018, 11:55
by Helgef
Hello egocarib, this has now been fixed in v2 :thumbup:. Hence, this is fine,

Code: Select all

Hotkey("a", Func("FnA").Bind(0))
Also fixed for settimer. See AutoHotkey v2 alpha (UPDATES).

Cheers.