ehdtkqorl123 Posted January 8, 2008 Share Posted January 8, 2008 When I use the following function, I would like to pass a function "func()" with a parameter.. GUICtrlSetOnEvent() For example, if there is no parameter, I use it like GUICtrlSetOnEvent(-1, "func") But if the function "func" has a parameter like func($variable){..} then how do I pass the parameter to GUICtrlSetIOnEvent? I dont think GUICtrlSetOnEvent(-1, "func($variable)") works... Is there a solution? Link to comment Share on other sites More sharing options...
Bowmore Posted January 8, 2008 Share Posted January 8, 2008 When I use the following function, I would like to pass a function "func()" with a parameter.. GUICtrlSetOnEvent() For example, if there is no parameter, I use it like GUICtrlSetOnEvent(-1, "func") But if the function "func" has a parameter like func($variable){..} then how do I pass the parameter to GUICtrlSetIOnEvent? I dont think GUICtrlSetOnEvent(-1, "func($variable)") works... Is there a solution?One workaround is to create a function that handles the event by calling the required function supplying values for any parameters. GUICtrlSetOnEvent(-1, "Eventfunc") Func Eventfunc() $Variable = 'Something' Realfunc($Variable) EndFunc Func Realfunc($Variable) ;Do stuff ;... EndFunc "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
ehdtkqorl123 Posted January 8, 2008 Author Share Posted January 8, 2008 YEa,,, I tried that method... Maybe that is the only way to handle it? Link to comment Share on other sites More sharing options...
ehdtkqorl123 Posted January 8, 2008 Author Share Posted January 8, 2008 Ah.. one bad thinga bout that is that I can't change the value of $variable dynamically whenever the Eventfunc() is called.. So I think it will end up with the same problem again One workaround is to create a function that handles the event by calling the required function supplying values for any parameters. GUICtrlSetOnEvent(-1, "Eventfunc") Func Eventfunc() $Variable = 'Something' Realfunc($Variable) EndFunc Func Realfunc($Variable) ;Do stuff ;... EndFunc Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 8, 2008 Share Posted January 8, 2008 (edited) This doesn't make any sense. What value would you pass if you could? If that value could be referenced by the function call, why couldn't it be referenced inside the function itself? What do you need to pass that would be knowable at event time but not at function execution time? The function does receive macros that are event specific:For GuiCtrlSetOnEvent: Within the called user function the control identifier can be retrieved with @GUI_CTRLID.If needed the windows handle and the control handle can be retrieved with @GUI_WINHANDLE or @GUI_CTRLHANDLE. Edited January 8, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now