Is it possible to send Function as argument?
Posted: Fri Feb 12, 2016 9:26 am
Normally if i use:
What will be sent to generalfunction as arguments would be variable a:s content, and result of "my_func".
However, right now i have a situation where it would be handy if i could actually send the function as it is, to be executed at later point, but is this possible?
What I am after with this in practice is, that I am about to create some buttons, which work exactly same, except, when they are being clicked, they are supposed to execute some function, like "StartGame()".
Therefore it would be handy if i could make only one button type, where i could send that function to be executed when that button is being clicked:
(partial code)
Is this possible to do somehow? Could i send a reference to a function for example somehow?
Code: Select all
generalfunction(a, my_func)However, right now i have a situation where it would be handy if i could actually send the function as it is, to be executed at later point, but is this possible?
What I am after with this in practice is, that I am about to create some buttons, which work exactly same, except, when they are being clicked, they are supposed to execute some function, like "StartGame()".
Therefore it would be handy if i could make only one button type, where i could send that function to be executed when that button is being clicked:
(partial code)
Code: Select all
p_Create_Button(FuncToUse)
evttable = {OnMouseUp = FuncToUse}