Is there an alternative for the removed IsFunc function in AHK V2?
I do not want to run the function itself (for this we could use try catch..), I want to know if the function exist for a convertor script.
Alternative for IsFunc function in V2? Topic is solved
Re: Alternative for IsFunc function
Code: Select all
fun(){
}
MsgBox Type(fun)
Re: Alternative for IsFunc function in V2?
- operator is
- check for Call/__Call props or methods(and in the bases, too)
Re: Alternative for IsFunc function in V2?
Thanks for the tips, I am just started to convert my mind to V2, excellent brain training material , but I feel like a noob again .
Code: Select all
#SingleInstance Force
#Requires AutoHotkey 2.0-beta.1
FunctionList := "
(
Abs
ASin
ACos
ATan
Buffer
CallbackCreate
CallbackFree
CaretGetPos
Ceil
Chr
ClipboardAll
ComCall
ComObjActive
ComObjArray
ComObjConnect
ComObject
ComObjFlags
ComObjFromPtr
ComObjGet
ComObjQuery
ComObjType
ComObjValue
ComValue
ControlFindItem
ControlGetChecked
)"
Loop Parse, FunctionList, "`n"
{
result.= A_LoopField " : " IsFunc(A_LoopField) "`n"
}
MsgBox(result)
return
IsFunc(FunctionName){
Try{
return %FunctionName%.MaxParams
}
Catch{
return 0
}
return
}
Re: Alternative for IsFunc function in V2?
Code: Select all
IsFunc(FunctionName){
Try{
return %FunctionName%.MaxParams
}
Catch{
return 0
}
return
}
Re: Alternative for IsFunc function in V2? Topic is solved
You are correct, I wanted to have the old ahk V1 IsFunc function, but read the documentation of IsFunc wrong.swagfag wrote: ↑28 Jul 2021, 15:29is at best a misnomer(perhaps u meant to write TryGetMaxParamsOrNull()?) and at worst a broken reimplementation of IsFunc(incorrect results for nullary and variadic functions, as well as ones of any arity that only declare optional parameters)Code: Select all
IsFunc(FunctionName){ Try{ return %FunctionName%.MaxParams } Catch{ return 0 } return }
This should be the correct code:
Code: Select all
IsFunc(FunctionName){
Try{
return %FunctionName%.MinParams+1
}
Catch{
return 0
}
return
}