I am seeing an unexpected result with the following code:
(I actually have two issues, but the latter is prolly just me.?. I'll explain more at end)
Code:
;rcb_test.ahk
;===============================================================================
test_msg2(text_2="") {
msgbox, % "Registered Function 2 Called: " . text_2 ;%
return
}
test_msg2("2 conventional call, not DLLCall...")
aFunc2 := registercallback("test_msg2")
string2 := "this is testing rcb 2 via dllcall"
result := dllcall(aFunc2,"str",string2)
If (ErrorLevel <> 0) {
msgbox, % "registercallback 2 was OK. Got error level of: " . ErrorLevel . " on use" ;%
}
;===============================================================================
The first issue I am seeing is with the RegisterCallback construct. The issue is that the code, as reflected above, yields an A4 error with the DLLCall. If, however, I change the RegisterCallback construct line to:
Code:
aFunc2 := registercallback("test_msg2","",1)
OR
If I remove the default parameter, altering the functions's definition to:
Code:
test_msg2(text_2) {
It works fine and Error_Level is not set on the DLLCall.
This kicked my arse a bit as I was thinking that an error with the RegisterCallback construct would have been able to be trapped with ErrorLevel, but that is not the case...
Is this considered to be normal operation?
...
Ok, the 2nd query: Why is the function printing the parameter text just file for a conventional call, but only prints the pointer when called via DLLCall? Is the DLLCall or RegisterCallback constructs in error?
Do I need to have the function be smarter and coded to react differently if called via a callback vs. a conventional call?
This seems to be a bit of an bug as I would expect the function's code to behave the same in both cases.?.
Thoughts? Plz advise. TIA. -t