mike2003 Posted November 3, 2014 Posted November 3, 2014 Are there commands to interrupt the current CASE block? Switch $a Case 1 ..... Case 2 .... if .... then "EXIT" .... Case 3 ..... EndSwitch
Moderators Melba23 Posted November 3, 2014 Moderators Posted November 3, 2014 mike2003,The easiest way is to reverse the logic like this: Switch $a Case 1 ..... Case 2 .... If Not .... Then ; Do something ; Else ; These lines are virtual ; Exit the Switch ; and do not need to appear EndIf .... Case 3 ..... EndSwitchAll clear? 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
mike2003 Posted November 3, 2014 Author Posted November 3, 2014 I know.I'm interested in commands such Next or Continue or Break.I could not find, but I think before I do that... Now I can not remember
Exit Posted November 3, 2014 Posted November 3, 2014 Continuecase continues with the next case statement. There is a exitcase statement missing in the language. $i = 2 Switch $i Case 1 MsgBox(262144, Default, "1", 0) Case 2 MsgBox(262144, Default, "2", 0) ContinueCase MsgBox(262144, Default, "after continuecase", 0) Case 3 MsgBox(262144, Default, "3", 0) EndSwitch App: Au3toCmd UDF: _SingleScript()
Solution Exit Posted November 3, 2014 Solution Posted November 3, 2014 A circumvention: Using case xx twice in conjunction with continuecase.Works as exitcase. $i = 2 Switch $i Case 1 MsgBox(262144, Default, "1", 0) Case 2 MsgBox(262144, Default, "2", 0) ContinueCase ; skip to next case statement MsgBox(262144, Default, "after continuecase", 0) Case 2 ; same case as above with no operation Case 3 MsgBox(262144, Default, "3", 0) EndSwitch App: Au3toCmd UDF: _SingleScript()
mike2003 Posted November 3, 2014 Author Posted November 3, 2014 (edited) It's strange, but it seems it works Case $Button1 GUICtrlSetData($Button1, "A") Case $Button1 ; Like "BREAK CASE" GUICtrlSetData($Button1, "B") Case $Button2 "continuecase" not needed Edited November 3, 2014 by mike2003
Moderators Melba23 Posted November 3, 2014 Moderators Posted November 3, 2014 mike2003,Interesting find. 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
Exit Posted November 3, 2014 Posted November 3, 2014 It's strange, but it seems it works Case $Button1 GUICtrlSetData($Button1, "A") Case $Button1 ; Like "BREAK CASE" GUICtrlSetData($Button1, "B") Case $Button2 "continuecase" not needed It is not strange, but normal behavior. Just Tidy the script. Case $Button1 GUICtrlSetData($Button1, "A") Case $Button1 ; this is the same "case". ; it will not be executed. See Help. ; "If more than one of the Case statements are true, only the first one is executed." GUICtrlSetData($Button1, "B") Case $Button2 There is no "Break Case" and no conditional processing. Here a solution, where a conditional "Break case" is used. $i = 1 $sw = InputBox("", "Enter 0 or 1", "0") Switch $i Case 1 If $sw = "1" Then ContinueCase ; skip to next case statement MsgBox(262144, Default, "Switch is off", 0) Case 1 MsgBox(262144, Default, "Switch is on", 0) EndSwitch App: Au3toCmd UDF: _SingleScript()
mikell Posted November 3, 2014 Posted November 3, 2014 $i = 1 $sw = InputBox("", "Enter 0 or 1", "0") Switch $i Case 1 If $sw = "1" Then ContinueCase ; skip to next case statement MsgBox(262144, Default, "Switch is off", 0) Case whatever you want (or something else) MsgBox(262144, Default, "Switch is on", 0) EndSwitch
mike2003 Posted March 17, 2015 Author Posted March 17, 2015 (edited) Looks like it works too! ContinueLoop Case $Button4 PrintMessage("OK4-1") if (1) Then ContinueLoop ;"BREAK CASE" PrintMessage("OK4-2") Edited March 17, 2015 by mike2003 Y3llo 1
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