OliverA Posted April 23, 2013 Share Posted April 23, 2013 Hi all i have a script with several func() I have stripped the code in a example like this: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hForm = GUICreate("Form1", 255, 237, -1, -1) $Button = GUICtrlCreateButton("Button1", 32, 80, 81, 33) $Input = GUICtrlCreateInput("", 120, 88, 97, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button MyFunc() EndSwitch WEnd Func MyFunc() _IsEmpty() MsgBox(0,0,"etc.") EndFunc Func _IsEmpty() If GUICtrlRead($Input) = "" Then MsgBox(16, "Error", "Empty", 0, $hForm) Return EndIf EndFunc Why When i have the Error MsgBox the Return don't stop the script? If i make in this way work: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hForm = GUICreate("Form1", 255, 237, -1, -1) $Button = GUICtrlCreateButton("Button1", 32, 80, 81, 33) $Input = GUICtrlCreateInput("", 120, 88, 97, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button MyFunc() EndSwitch WEnd Func MyFunc() If GUICtrlRead($Input) = "" Then MsgBox(16, "Error", "Empty", 0, $hForm) Return EndIf MsgBox(0, 0, "etc.") EndFunc ;==>MyFunc But i'd like to make a separate Func() because i need to check te same things for other Func() and i don't wont to write the same thing many times. Where is my mistake? Thanks to all I'M QUIT FROM THIS FORUM! It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself. In what way? It's easy...just search on google For that people, wish you the best way, Oliver Astone Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 23, 2013 Moderators Share Posted April 23, 2013 OliverA,Get the _IsEmpty function to return a flag indicating the result - then you can use that flag to determine what to do next: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hForm = GUICreate("Form1", 255, 237, -1, -1) $Button = GUICtrlCreateButton("Button1", 32, 80, 81, 33) $Input = GUICtrlCreateInput("", 120, 88, 97, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button MyFunc() EndSwitch WEnd Func MyFunc() If _IsEmpty() = True Then Return Else MsgBox(0, 0, "etc.") EndIf EndFunc ;==>MyFunc Func _IsEmpty() If GUICtrlRead($Input) = "" Then MsgBox(16, "Error", "Empty", 0, $hForm) Return True Else Return False EndIf EndFunc ;==>_IsEmptyAll 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 Link to comment Share on other sites More sharing options...
OliverA Posted April 23, 2013 Author Share Posted April 23, 2013 Melba thanks, but if i have more then one in the same _IsEmpty like: If GUICtrlRead($Input) = "" Then MsgBox(16, "Error", "Empty", 0, $hForm) Return EndIf If GUICtrlRead($Input2) = "" Then MsgBox(16, "Error", "Empty", 0, $hForm) Return EndIf If GUICtrlRead($Input3) = "" Then MsgBox(16, "Error", "Empty", 0, $hForm) Return EndIf How i can do? I'M QUIT FROM THIS FORUM! It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself. In what way? It's easy...just search on google For that people, wish you the best way, Oliver Astone Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 23, 2013 Moderators Share Posted April 23, 2013 OliverA, I would do something like this: expandcollapse popup#include <GUIConstantsEx.au3> Global $aInput[4] = [3] $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("Check", 10, 10, 80, 30) $aInput[1] = GUICtrlCreateInput("", 10, 50, 200, 20) $aInput[2] = GUICtrlCreateInput("", 10, 70, 200, 20) $aInput[3] = GUICtrlCreateInput("", 10, 90, 200, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton ; See what the function returns If _Check_Inputs() = True Then MsgBox(64, "Checked", "All inputs valid") Else MsgBox(48, "Checked", "Some inputs invalid") EndIf EndSwitch WEnd Func _Check_Inputs() ; Set a flag $fCorrect = True ; Now check the inputs For $i = 1 To $aInput[0] If GUICtrlRead($aInput[$i]) = "" Then MsgBox(48, "Error", "Check box " & $i & " is empty") ; Clear the flag $fCorrect = False EndIf Next ; And return the flag Return $fCorrect EndFunc Does that fit the bill? 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...
OliverA Posted April 23, 2013 Author Share Posted April 23, 2013 Sure, thanks I'M QUIT FROM THIS FORUM! It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself. In what way? It's easy...just search on google For that people, wish you the best way, Oliver Astone Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 23, 2013 Moderators Share Posted April 23, 2013 OliverA, My pleasure. 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...
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