I'm getting older & stupider... what am I missing with the below, as I can't get it to add the numbers. Perhaps Function Returns don't work with these Matrix1 Utility commands? What am I forgetting here!?
`--- This Works, traditional/default way
Print "Testing default: " ; Func_Add_Stuff(1,2,3)
`Now I'm trying to see if the below is possible; only using two arguements instead of the three, but neither give the desired result.
Print ""
Ptr_Add_stuff = Get Ptr To Function ("Func_Add_Stuff")
Print "Testing Ptr Call: " ; Call Function Ptr (Ptr_Add_stuff,1,2,3)
Print "Testing Name Call: " ; Call Function Name ("Func_Add_stuff",1,2,3)
Print ""
`Note only two arguements are being used, but still not right.
Print "Testing Ptr Call: " ; Call Function Ptr (Ptr_Add_stuff,1,2)
Print "Testing Name Call: " ; Call Function Name ("Func_Add_stuff",1,2)
Wait Key
End
Function Func_Add_Stuff(Val_1 As integer, Val_2 as integer, Val_3 as integer)
Local Func_Return as Integer
Print "Inside function"
Func_Return = Val_1 + Val_2 + Val_3
Endfunction Func_Return
EDIT: A little tinkering gave some results;
`--- This Works, traditional/default way
Print "Testing default: " ; Func_Add_Stuff(1,2,3)
`The below now works, when expected arguments are given.
Print ""
Ptr_Add_stuff = Get Ptr To Function ("Func_Add_Stuff")
OMG_r_you_cirrus = Call Function Ptr (Ptr_Add_stuff,1,2,3)
Print "Testing Ptr Call: " ; OMG_r_you_cirrus
OMG_r_you_cirrus = Call Function Name ("Func_Add_stuff",1,2,3)
Print "Testing Name Call: " ;OMG_r_you_cirrus
Print ""
`If less than arguments are given the return fails
OMG_r_you_cirrus = Call Function Ptr (Ptr_Add_stuff,1,3)
Print "Testing Ptr Call with less than expected: " ; OMG_r_you_cirrus
OMG_r_you_cirrus = Call Function Name ("Func_Add_stuff",1,2)
Print "Testing Name Call with less than expected: " ; OMG_r_you_cirrus
Print ""
`If more than arguments are given, the return works whilst dropping the extra arguments.
OMG_r_you_cirrus = Call Function Ptr (Ptr_Add_stuff,1,3,8,5)
Print "Testing Ptr Call with more than expected: " ; OMG_r_you_cirrus
OMG_r_you_cirrus = Call Function Name ("Func_Add_stuff",1,2,4,5)
Print "Testing Name Call with more than expected: " ; OMG_r_you_cirrus
Wait Key
End
Function Func_Add_Stuff(Val_1 As integer, Val_2 as integer, Val_3 as integer)
Local Func_Return as Integer
Print "Inside function"
Func_Return = Val_1 + Val_2 + Val_3
Endfunction Func_Return