I didn't thoroughly check the forums, but I didn't see anything about it in the _H forum anyway. Originally, I had tried sending varadic parameters via DllCall, which didn't work, and I'm assuming there's not a way to get that working. But, I just noticed that you can't use ahkPostFunction on a function that uses a varadic parameter. I tried and it crashed. So then I compromised and tried using something like func(var,o1:="",o2=""). That also doesn't work; say if you send it 2 parameters, the third (o2) will contain "Str". If you leave two optional parameters blank, it will crash. I finally settled for func(var,o1,2) and just sent blank/empty variables when they weren't needed.
My question is: is this unavoidable? Could varadic/optional function parameters possibly work?
ahk[Post]Function parameters bug
- Masonjar13
- Posts: 1555
- Joined: 20 Jul 2014, 10:16
- Location: Не Россия
- Contact:
Re: ahk[Post]Function parameters bug
Unfortunately not.
However you can share function objects to call the function:
However you can share function objects to call the function:
Code: Select all
ahk:=AhkThread("
(
#Persistent
SetBatchlines, -1
cFun:=Func(""fun"")
pFun:=&cFun
fun(var*){
MsgBox `% var.1 ""``n"" var.2
}
)")
cFun:=Object(ahk.ahkFindFunc("fun"))
; you can also use Alias
; Alias(cFun,ahk.ahkgetvar("cFun",1))
; or use a pointer
; cFun:=Object(ahk.ahkgetvar("pFun"))
cFun.Call("a","b")
- Masonjar13
- Posts: 1555
- Joined: 20 Jul 2014, 10:16
- Location: Не Россия
- Contact:
Re: ahk[Post]Function parameters bug
That's what I thought. Though, what you suggested is pretty much perfect for my use case, so I'll try doing that. Thank you!
Who is online
Users browsing this forum: No registered users and 52 guests