Callback?

BlitzMax Forums/BlitzMax Beginners Area/Callback?

Telemental(Posted 2005) [#1]
Does blitzmax support callback functions? I.E., can I store a function in a variable somehow then call it from that variable (an exec() command)?

Thanks,
Sekeol


Red(Posted 2005) [#2]
Yes
Function TEST:string(x:int)
Notify x
EndFunction 

Local MyFunc:string(var:int) 'CALLBACK function
MyFunc = TEST
MyFunc(0) 'diplay message


2nd example
Function RepeatMe(myFunc(x:int))
myFunc(0) 'diplay message
myFunc(1) 'diplay message
myFunc(2) 'diplay message
EndFunction 

Function TEST(x:int)
Notify x
EndFunction 

RepeatMe(TEST)




Telemental(Posted 2005) [#3]
Thanks. I actually had it close... except I was assigning the function to the variable with the () suffix. Oops.