DWad Posted July 1, 2009 Share Posted July 1, 2009 Background - I have a Select Case statement with 18 possible cases. I want to close my GUI when one of those cases occurs, but for ALL other cases, I want to leave the GUI alone. The way I did it originally was to add a line to close the GUI in each of those 18 cases, but that means adding 18 more lines of code to do one function. Is there a way to say (for example) "If case = case 1 through case 18, then closeGUI()"? Or a better way to do this? Pseudo code of my current script- While1 Select Case 1 $msg=ms1 closeGUI() Case 2 $msg=ms2 closeGUI() Case 3 $msg=ms3 closeGUI() Case 4 $msg=ms4 closeGUI() EndSelect Wend For this particular script, the speed increase would be noticeable, but it makes my code look messy to have 18 extra lines of code, and I want to try to get my future scripts cleaner/faster. Thanks all, -DWad Link to comment Share on other sites More sharing options...
Minikori Posted July 1, 2009 Share Posted July 1, 2009 Background - I have a Select Case statement with 18 possible cases. I want to close my GUI when one of those cases occurs, but for ALL other cases, I want to leave the GUI alone. The way I did it originally was to add a line to close the GUI in each of those 18 cases, but that means adding 18 more lines of code to do one function. Is there a way to say (for example) "If case = case 1 through case 18, then closeGUI()"? Or a better way to do this? Pseudo code of my current script- While1 Select Case 1 $msg=ms1 closeGUI() Case 2 $msg=ms2 closeGUI() Case 3 $msg=ms3 closeGUI() Case 4 $msg=ms4 closeGUI() EndSelect Wend For this particular script, the speed increase would be noticeable, but it makes my code look messy to have 18 extra lines of code, and I want to try to get my future scripts cleaner/faster. Thanks all, -DWadThis would cut down on lines, but it'd be a long line: Select Case $msg=ms1 or $msg=ms2 or $msg=ms3;... CloseGUI() EndSelect For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com Link to comment Share on other sites More sharing options...
Zisly Posted July 1, 2009 Share Posted July 1, 2009 Switch GuiGetMsg() Case ms1,ms2,ms3, ms4 closeGUI() EndSwitch Link to comment Share on other sites More sharing options...
Authenticity Posted July 1, 2009 Share Posted July 1, 2009 Switch Random(1, 5, 1) Case 1 ConsoleWrite('Lorem ') ContinueCase Case 2 ConsoleWrite('ipsum ') ContinueCase Case 3 ConsoleWrite('dolor ') ContinueCase Case 4 ConsoleWrite('sit ') ContinueCase Case Else ConsoleWrite('amet' & @LF) EndSwitch Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 1, 2009 Moderators Share Posted July 1, 2009 Authenticity, Love the quote! ;-) M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
DWad Posted July 7, 2009 Author Share Posted July 7, 2009 Zisly got me slightly closer. I ended up using a variable that would close the GUI after the Switch statements unless it got to the case else (which would set the variable to keep the GUI open). Is there no way to say something along the lines of "If case 1,2,3 or 4, do this, else do that"? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 7, 2009 Share Posted July 7, 2009 Case ElseKeyword Select...Case...EndSelect BlackLumiere 1 - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. 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