| || CALLFUNC will execute the function pointer that was bound by using BIND. |
Syntax: CALLFUNC(fptr, param1, param2, ...)
CALLFUNC(FPtr, 10, 20)
PRINT CALLFUNC(FPtr2, 10, 20)
Depending on how you BIND your function pointer, you can either call CALLFUNC as a statement or a function. Make sure to supply the necessary number of parameters, else you will receive a compile error. Passing function pointers as parameters is not yet implemented, but you can read up on Chapter 11 to see how to emulate this.
CALLFUNC requres parentheses in some cases:
' Do things...
function procedure2 as long
procedure2 = 1
dim lres as long
dim fnptr1 as integer
dim fnptr2 as integer
bind fnptr1 to procedure1
bind fnptr2 to procedure2
callfunc fnptr1 'This works
callfunc fnptr2 'This also works
lres=callfunc(fnptr2) 'This doesn't work. Compiler error
lres=callfunc fnptr2 'This doesn't work. Compiler error
lres=(callfunc(fnptr2)) 'This WORKS!!!