Ahh, so I could use the expression itself to check if the function was called. Thanks.
After a bit of testing, here is a general way to make sure if a function was called:
Code: Select all
str := "1"
;str := "2"
obj := ["aaa", "bbb", "ccc"]
;obj := ["aaa", "bbb"]
# := 0, IsFunc("fun" str) ? (fun%str%(obj*), # := 1) : (# := 2)
if(# = 0)
MsgBox, % "Too few parameters."
else if(# = 1)
MsgBox, % "Function was called."
else if(# = 2)
MsgBox, % "Non-existent function."
fun1(p1, p2, p3) {
MsgBox, fun1()
}
IsFunc() first checks, if the function exists (
in case we're calling a non-existent function through a dynamic call, which would revert to calling the
__Call() meta-function of the base object (and thus only set the return value of the function to an empty string and got the rest of the expression evaluated)). Supposing we're not using the dynamic call to the non-existing function, if the function got too few parameters,
# := 2 will never be evaluated.
Edit: for more info, see
this thread by Lexikos.