« What's on your mind? » - Page 213 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=17&t=52&p=303516#p303516
There are places here and there where AHK v1 could be improved re. error handling.
(Note: although considerations have to be made re. 'breaking changes'.)
Code: Select all
;AHK v1
;q:: ;test 'or' as a parameter
;note: 'or' is not allowed as a variable name in AHK v2
ol := "a"
ot := "b"
or := "c"
orr := "c"
ob := "d"
varname := "or"
MsgBox, % MyFunc(ol, ot, or, ob)
MsgBox, % MyFunc(ol, ot, %varname%, ob)
MsgBox, % MyFunc(ol, ot, 1 or 2, ob)
MsgBox, % MyFunc(ol, ot, orr, ob)
return
MyFunc(oParams*)
{
local
vOutput := ""
for vKey, vValue in oParams
vOutput .= vKey " " vValue "`r`n"
return vOutput
}
Code: Select all
;AHK v2
;note: 'or' is not allowed as a variable name in AHK v2
ol := "a"
ot := "b"
;or := "c"
orr := "c"
ob := "d"
varname := "or"
%varname% := "c"
;MsgBox(MyFunc(ol, ot, or, ob))
MsgBox(MyFunc(ol, ot, %varname%, ob))
MsgBox(MyFunc(ol, ot, 1 or 2, ob))
MsgBox(MyFunc(ol, ot, orr, ob))
MyFunc(oParams*)
{
local
vOutput := ""
for vKey, vValue in oParams
vOutput .= vKey " " vValue "`r`n"
return vOutput
}