Function Pointers

Started by jsp, April 26, 2019, 12:09:37

Previous topic - Next topic

jsp

Hi,
I try some code from BlitzMax on NG and it seems the syntax of Function pointers has changed.
Nothing found in the documentation.
How is it done in NG now?


Field  CallBackFunction:Int( FormTimer:TFormTimer )

Method Create:TFormTimer( Name:String,Hertz:Float,Event:TEvent=Null,CallBackFunction( FormTimer:TFormTimer )=Null, Obj:Object=Null )
Self.Name  = Name
Self.Hertz = Hertz
Self.Event = Event
Self.CallBackFunction = CallBackFunction
Self.Extra = Obj
Self.Timer = CreateTimer(Hertz,Event)
Return Self
End Method
-jsp-

Derron

It is done as before - just think of "function:int(param:int)" not being the same as "function(param:int)" if you are using "SuperStrict" (void is now a valid return type).

so
Method Create:TFormTimer( Name:String,Hertz:Float,Event:TEvent=Null,CallBackFunction( FormTimer:TFormTimer )=Null, Obj:Object=Null )
becomes
Method Create:TFormTimer( Name:String,Hertz:Float,Event:TEvent=Null,CallBackFunction:Int( FormTimer:TFormTimer )=Null, Obj:Object=Null )

as you defined the callback to be:
Field  CallBackFunction:Int( FormTimer:TFormTimer )

bye
Ron

jsp

Oh I see, great!
Thanks.
-jsp-