CallFunction() for Callback systems

Share your advanced knowledge/code with the community.
cederavic
Posts: 30
Joined: Tue Feb 25, 2014 6:49 am

CallFunction() for Callback systems

Post 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.
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: CallFunction() for Callback systems

Post by Fred »

You should be able to use Prototype natively as well :)
cederavic
Posts: 30
Joined: Tue Feb 25, 2014 6:49 am

Re: CallFunction() for Callback systems

Post by cederavic »

ho.. I did not though of that, i'll try :)
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: CallFunction() for Callback systems

Post 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")
cederavic
Posts: 30
Joined: Tue Feb 25, 2014 6:49 am

Re: CallFunction() for Callback systems

Post by cederavic »

Works great, Thanks Fred :)
Post Reply