Page 1 of 1

CallFunction() for Callback systems

Posted: Tue Feb 25, 2014 9:52 pm
by cederavic
Little tricks to execute a procedure with its "pointer"

Code: Select all

;/**
; * Execute and return the @Procedure() passing parms object as parameter
; */
Procedure CallFunction(*proc, *parms)
	!if (p_proc!= null) return p_proc(p_parms);
EndProcedure
	
Procedure TestCall(value.s)
	Debug value
	ProcedureReturn #True
EndProcedure

Debug CallFunction(@TestCall(), @"lalala")
Although, the SpiderBasic.js need to be cleaned from asm code.

Re: CallFunction() for Callback systems

Posted: Tue Feb 25, 2014 11:06 pm
by Fred
You should be able to use Prototype natively as well :)

Re: CallFunction() for Callback systems

Posted: Wed Feb 26, 2014 6:10 am
by cederavic
ho.. I did not though of that, i'll try :)

Re: CallFunction() for Callback systems

Posted: Wed Feb 26, 2014 10:18 am
by Fred
Here is the code for the record:

Code: Select all

;/**
; * Execute and return the @Procedure() passing parms object as parameter
; */
   
Procedure TestCall(value.s)
   Debug value
   ProcedureReturn #True
EndProcedure

Prototype TestCallPrototype(value.s)

FunctionPointer.TestCallPrototype = @TestCall()
FunctionPointer("Hello")

Re: CallFunction() for Callback systems

Posted: Wed Feb 26, 2014 6:33 pm
by cederavic
Works great, Thanks Fred :)