bouncingmolar Posted November 28, 2008 Share Posted November 28, 2008 (edited) I have a menu (GUICtrlCreateMenu) with a few options. Many of the options share similar functions except maybe a change of variable. Is there an easier way to write this without the repitition. (ie in my example, write functiona b c d e f g h just once) Thanks expandcollapse popupSwitch Case $menuoption1 $function="function1" functiona functionb functionc functiond functione functionf functiong functionh Exitloop Case $menuoption2 $function="function2" functiona functionb functionc functiond functione functionf functiong functionh Exitloop Case $menuoption3 $function="function3" functiona functionb functionc functiond functione functionf functiong functionh Exitloop Case $menuoption4 totally different set of commands totally different set of commands totally different set of commands totally different set of commands Endswitch Edited November 28, 2008 by bouncingmolar Link to comment Share on other sites More sharing options...
GEOSoft Posted November 28, 2008 Share Posted November 28, 2008 (edited) I have a menu (GUICtrlCreateMenu) with a few options. Many of the options share similar functions except maybe a change of variable. Is there an easier way to write this without the repitition. (ie in my example, write functiona b c d e f g h just once) Thanks expandcollapse popupSwitch Case $menuoption1 $function="function1" functiona functionb functionc functiond functione functionf functiong functionh Exitloop Case $menuoption2 $function="function2" functiona functionb functionc functiond functione functionf functiong functionh Exitloop Case $menuoption3 $function="function3" functiona functionb functionc functiond functione functionf functiong functionh Exitloop Case $menuoption4 totally different set of commands totally different set of commands totally different set of commands totally different set of commands EndswitchFirst off you can't use switch like that. What you have there is actually the proper structure for Select. Almost, at any rate. Func _RunFuncs($iMsg) Switch $iMsg Case $menuoption1 $function="function1" Case $menuoption2 $function="function2" Case $menuoption3 $function="function3" Case $menuoption4 EndSwitch If $iMsg <> $menuoption4 Then functiona functionb functionc functiond functione functionf functiong functionh Else totally different set of commands totally different set of commands totally different set of commands totally different set of commands EndIf EndFunc Edited November 28, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
martin Posted November 28, 2008 Share Posted November 28, 2008 I have a menu (GUICtrlCreateMenu) with a few options. Many of the options share similar functions except maybe a change of variable. Is there an easier way to write this without the repitition. (ie in my example, write functiona b c d e f g h just once) Thanks expandcollapse popupSwitch Case $menuoption1 $function="function1" functiona functionb functionc functiond functione functionf functiong functionh Exitloop Case $menuoption2 $function="function2" functiona functionb functionc functiond functione functionf functiong functionh Exitloop Case $menuoption3 $function="function3" functiona functionb functionc functiond functione functionf functiong functionh Exitloop Case $menuoption4 totally different set of commands totally different set of commands totally different set of commands totally different set of commands EndswitchMaybe replace the list with functionaTOh() and in that function have the list. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
GEOSoft Posted November 28, 2008 Share Posted November 28, 2008 Maybe replace the list with functionaTOh() and in that function have the list.That would work too.It depends on what you are doing in the rest of your code. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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