I was experimenting with the code and simply this works : Public sub main() calll(twotimes(3)) end
Public Sub twotimes(a As Integer) As Integer Print a a *= 2 Print a Return a End Public Sub calll(cb As Pointer) Print "should be printed twice" End output: 3 6 should be printed twice External function using callback works fine too: in freeglut_std.h: glutDisplayFunc( void (* callback)( void ) ); in Gambas: Public Extern glutDisplayFunc(callback As Pointer) call simply: glutDisplayFunc(screen_draw) when public sub screen_draw() ... end Tomek. ----- Original Message ----- From: "tobias" <tobiasb...@web.de> To: "mailing list for gambas users" <gambas-user@lists.sourceforge.net> Sent: Thursday, 11 August, 2011 9:41:05 PM Subject: Re: [Gambas-user] Callback hi, > Or, see code: > > To class named "Twotimes": > > Static Public Function _call(x As Integer) As Integer > Return x * 2 > End > > > Then somewhere else: > > ''This is the function that accepts callbacks. > Public Function testing(x As Integer, ofunc As Object) As Integer > Return ofunc(x) > End > > > ''Here is how to call it. > Dim ChosenFunction As Object > > ChosenFunction = New Twotimes ''Here you can set the callback function. > Print testing(2, ChosenFunction) > > > Jussi this is a very pretty workaround. i'll use that! thanks ------------------------------------------------------------------------------ Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user ------------------------------------------------------------------------------ Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user