[AHK_H v2] Macro Functions

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

[AHK_H v2] Macro Functions

09 Oct 2017, 16:02

I have implemented experimental macro functions.
Now a function definition can be prefixed with 'macro ' (followed by space, not tab!) to create a macro instead of function.
Macro will use caller's scope for all variables except for parameters, function parameters will be resolved to local variables.
Dynamic variable references will also use caller's scope.

Global and static variables are not supported in macros.

Code: Select all

myfun("MyValue")
fun("AnotherValue")
MsgBox var
myfun(value:=""){
	fun(value)
	MsgBox var
}
macro fun(value){
	var:=value
}
Let me know what you think about it ;)
Deref function example
Alternative deref function example
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: [AHK_H v2] Macro Functions

09 Oct 2017, 16:05

Restored reply from Helgef from google cache.

This is nice. :thumbup:
Eg, to reduce index transform clutter in loops,

Code: Select all

loop 8
	Msgbox 2**i()
macro i(){
	return A_Index-1
}
This crashes,

Code: Select all

macro m(){
	0
}
an error would be nicer, or if it was just inlined ;)
Cheers.
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: [AHK_H v2] Macro Functions

09 Oct 2017, 16:05

That seems to be a problem in v2, it is not related to macro, I have opened a bug report: https://autohotkey.com/boards/viewtopic ... 33#p158449

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 22 guests