Acce Posted July 9, 2020 Share Posted July 9, 2020 (edited) Hi Im having a problem wiich kinda blows my mind I have a finished GUI 100% workin or rather 99% % since im trying to add some error handling.My GUI also handles a 2nd GUI and the code is based on this example: https://www.autoitscript.com/wiki/Managing_Multiple_GUIs So Im hoping to avoid posting my entire code since its a lot so I will try to explain. I have created a settings panel with a few combo´s, checkboxes , selectors and what not : realized today that some of the settings are contradictory and instead of disabling some choices I would rather tell the end user what went wrong. So the end code works like this: expandcollapse popupFunc On_Button() Switch @GUI_CtrlId ; See which button sent the message Case $idRadio1 Get_RadioData() Case $idRadio2 Get_RadioData() Case $idCheckbox Get_CheckboxData() Case $idComboBox Get_WaitingData() Case $idComboBox2 Get_WaitingData() Case $idComboBox3 Get_WaitingData() Case $idComboBox_fin Get_finishData() Case $g_idButton2 GUICtrlSetState($g_idButton2, $GUI_DISABLE) gui2() Case $g_idButton3 GUIDelete($g_hGUI2) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<< GUICtrlSetState($g_idButton2, $GUI_ENABLE) Case $g_idButton4 ; <-------------- Start/OK btn Get_ListData() Get_RadioData() Get_SliderData() Get_CheckboxData() Get_WaitingData() Get_finishData() errCheck() if $errCheck <> True Then GUIDelete($g_hGUI1) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<< GUIDelete($g_hGUI2) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<< PreStart() Else SoundPlay( @ScriptDir & "\Sounds\Error.mp3") MsgBox(262144 ,"Error", $errMsg) EndIf Case $idRCombo ;Selection Change $eVar = GUICtrlRead($idRCombo) GUI_Selection_Change($eVar) Case $g_idButton5 ;OK btn popup $eVar = GUICtrlRead($idRCombo2) if _GUICtrlListBox_GetCount($List1) < 3 Then GUICtrlSetData($List1, $eVar) GUIDelete($g_hGUI2) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<< GUICtrlSetState($g_idButton2, $GUI_ENABLE) Get_ListData() Else MsgBox(262144 ,$errTitle, "Maximum 3 targets supported by script") EndIf case $clearall ; CLear BTN region GUICtrlSetData($List1, "") Get_ListData() EndSwitch EndFunc ;==>On_Button And the problem is whit my error check function Func errCheck() Local $iCnt = _GUICtrlListBox_GetCount($List1) if $StartDelay = "True" And $iCnt = 0 Then ; <Just for testing $errCheck = True $errTitle = "Err - No data selected" $errMsg = $iCnt EndIf If $errCheck <> True Then if $StartDelay = "True" And $Data = "Select" Then $errCheck = True $errTitle = "Err - Click on Select" $errMsg = "When delay is selected you need select" EndIf EndIf If $errCheck <> True Then if $StartDelay = "True" And $hDelay = "0H" And $mDelay = "0M" Then $errCheck = True $errTitle = "Contradiction Error" $errMsg = "Delayed startup Selected. but Hour and minute timers set to 0" EndIf EndIf EndFunc So what happens is this , The error check gets activated and when I change the settings it looks like the error check still checks the old data , however I log the variables in a txt file and I can see that they are changed so what baffles me is that the error checks gets activated. When I relaunch the window and selects settings which avoids the errorr check the script runs , but when I select back to settings which should activate the error check same problem. So somehow it looks like the error check uses old data or I dont know , really strange problem.. any suggestions ? Edited July 9, 2020 by Acce Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 9, 2020 Moderators Share Posted July 9, 2020 (edited) Acce, Add some errorchecking to see what happens in the various Get_*Data() functions. From your description of the problem I suspect that these functions are not actually reading the new state of the reset controls. M23 P.S. And having now seen the "Maximum 3 targets supported by script" comment I suggest reading the Forum rules before you post again. Edited July 9, 2020 by Melba23 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...
Acce Posted July 9, 2020 Author Share Posted July 9, 2020 Hi thanks for your reply and info regarding rules , I dont think my little script is against any rules ? "From your description of the problem I suspect that these functions are not actually reading the new state of the reset controls. " - these get*data functions are actually the functions that sets alle variables. What I tried now is to set a global variables like so $Global $rData It gets updated elsewhere in the code, Have striped the error code a bit for error checking a error check code And when I read it just before err_check() Func it has the expected value , Also strangely enough it has expected data in the error function . However after this code: MsgBox(262144 ,"Info box", $rData ) ; < -- Found Here if $rData = "" Then $errCheck = True $errTitle = "Err - Unexpected Error" $errMsg = "error: " & $rData ;< Returns blank here ????? EndIf Also reading the var after this func returns expected result Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 9, 2020 Moderators Share Posted July 9, 2020 Acce, Of course it will be blank at that point - the If statement is only true if that is the case! if $rData = "" Then 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...
Acce Posted July 9, 2020 Author Share Posted July 9, 2020 I dont understand maybe I looked at too many numbers today and my brain is not with me anymore , lol In my mind if this gets read with expected result: MsgBox(262144 ,"Info box", $rData ) ; < -- Found Here Then this if statement shouldn't be activated ? if $rData = "" Then But it gets activated , its almost like the if statement change the value of $rdata Link to comment Share on other sites More sharing options...
Acce Posted July 9, 2020 Author Share Posted July 9, 2020 sounds like quantum physics to me, lol can $rData be something at the same time its nothing ? Link to comment Share on other sites More sharing options...
Dan_555 Posted July 9, 2020 Share Posted July 9, 2020 You can test the code: Global $rData $rData ="r2D2" Test() CW(" 1>>" & $rData & "<<") CW("") $rData ="" Test() CW(" 2>>" & $rData & "<<") Func Test() Local $errCheck, $errTitle, $errMsg ;MsgBox(262144, "Info box", $rData) ; < -- Found Here CW("Before>" & $rData & "<") If $rData = "" Then $errCheck = True $errTitle = "Err - Unexpected Error" $errMsg = "error: " & $rData ;< Returns blank here ????? CW(" > " & $rData & "<") EndIf EndFunc ;==>Test Func CW($txt) ConsoleWrite($txt & @CRLF) EndFunc ;==>CW you should get following output: Quote Before>r2D2< 1>>r2D2<< Before>< > < 2>><< Some of my script sourcecode Link to comment Share on other sites More sharing options...
Acce Posted July 9, 2020 Author Share Posted July 9, 2020 OK I think I found the problem. I had forget to reset the var $errCheck to false after clicking ok btn , now I feel a little silly :=) thanks for taking interest anyway 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