Sign in to follow this  
Followers 0
crushyna

Error check implementation (problem with loop exit)

1 post in this topic

Hi everyone!
I'm developing small testing tool for new software in my company.
Tool itself is working correctly (it follows scripted test commands one by one), but I'm trying to develop an error checking function.

Mechanics are simple: every time software (external) shows specific error (via window class), program asks for next step. Continue, or abort test (and return to main GUI)?
The error check function is switched on/off via Checkbox in GUI.

Here are some code fragments:

Checkbox:

Global $idCheckbox1 = GUICtrlCreateCheckbox("Enable TP.net error handling", 352, 40, 249, 17)
    GUICtrlSetFont(-1, 12, 400, 0, "Calibri")
    GUICtrlSetColor(-1, 0x000000)

 

Checkbox switch:

GUISetState(@SW_SHOW)
Local $Choosen

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

        Case $idCheckbox1
            If _IsChecked($idCheckbox1) Then
                $cSwitch1 = 1
            Else
                $cSwitch1 = 0
            EndIf

        Case $idAddTest
(and so on...)

 

Function call:

(alot of ElseIf commands...)

                    ElseIf $aItem = $idOperatorIn Then
                    WywolanieOkna()
                    WinActivate($hFSO)
                    ControlClick($hFSO, "", "[NAME:lblCashierNumber]")
                    Sleep($Sleep_05)
                    Send("0000019{Enter}19{Enter 2}")
                    Sleep($Sleep_75)

                EndIf

                #EndRegion ### START ELSEIF ARMY ###

        Next
        If $cSwitch1 = 1 Then
            MsgBox( 0, "Error check!", "Error check ON!")  /// just for testing purposes
            CheckError()
        Else
            Return
        EndIf
    EndSwitch
WEnd


Classic _IsChecked function:

Func _IsChecked($idControlID)
    Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

 

And Checkerror() function itself:

Func CheckError()
    Local $Answer
    If ControlCommand($hMsgPanel, "", "[NAME:panelMsgBox]", "IsEnabled", "") Then
;~      Sleep($Sleep_05)
        $Answer = MsgBox(52, "Error!", "An error occured! Continue testing?")
;~      Sleep($Sleep_05)
        Switch $Answer
            Case 6
                MsgBox(0, "Error!", "Test will now continue.", 3)
                Send("{Enter}")
                WinActivate($hWnd)
                Return
            Case 7
                MsgBox(64, "Error!", "Test cancelled.", 5)
                $ElseIfArmyOff = 1
                ControlClick($hMsgPanel, "", "[NAME:cmdOK]")
                WinActivate($AppName)
                #cs
                    MsgBox( 0, "test1", $idTSList)
                    Local $idTSListCopy
                    For $i = 0 to _GUICtrlListView_GetItemCount($idTSList) - 1\
                #ce
                $idTSListCopy = _GUICtrlListView_GetItemTextString($idTestCaseList, $LoopCount)
                ExitLoop
        EndSwitch
    EndIf
    Return 1
EndFunc   ;==>CheckError


Problem is: i can't make this function (CheckError() ) return to main gui state, that means: break the If/ElseIf loop.
The switch is working correctly (MsgBox on error shows only when it's activated).
Checkerror() function works correctly - recognizes the error, stops script until decision is made. But it doesn't terminate If/ElseIf loop.

Any help appreciated!

Share this post


Link to post
Share on other sites



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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • IamKJ
      By IamKJ
      So I have a lot of different functions in the little program I'm making.  Most of them use the Do statement, such as finding images, clicking buttons, etc.
       
      The question I have is how would I be able to both
      1) Create a hotkey to pause whatever I am doing at the moment.  If I have to put something into every function in the program, I don't mind.
      2) Create a hotkey to exit whatever I am doing and stop all loops or commands and bring back the main GUI?
    • ur
      By ur
      I have created an exit function and registered using OnAutoItExitRegister.But it is not running when I close the app from taskbar or even with normal exit during end.
       
      Below is the part of code and the included files.
      #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <WinAPIFiles.au3> #include <Date.au3> #include <file.au3> #include <Array.au3> #include <String.au3> OnAutoItExitRegister("Exit_Program") Func Exit_Program() LoggingMainScr("Entered Exit_Program") Local $exitmethod = ["Natural closing", "close by Exit function", "close by clicking on exit of the systray","close by user logoff","close by Windows shutdown"] ExitProgram("Exit with exit code: "& @exitCode & " And because of: " & $exitmethod[@exitmethod],@exitmethod) EndFunc Func ExitProgram($sReason="Exit by user",$sCode=0) LoggingMainScr($sReason) if $sCode <> 0 then LoggingMainScr("stopped before completion") FileDelete(@ScriptDir&"\Machines*.txt") FileDelete(@ScriptDir&"\PsExec.exe") FileDelete(@ScriptDir&"\HyperVMachines.ps1") FileDelete(@ScriptDir&"\VMwareMachines.ps1") EndFunc Func LoggingMainScr($sMessage) LoggingDefault($sMessage,@ScriptDir&"\MainScr_Logging.log") EndFunc Func LoggingDefault($sMessage,$sLogFile=@ScriptDir&"\Logging.log") If $sMessage = "" Then FileWriteLine($sLogFile, "") Else FileWrite($sLogFile,_NowCalc() & " :: " & $sMessage&@CRLF) EndIf EndFunc Any suggestion.
       
    • jannikrendl
      By jannikrendl
      Hey guys,
      I would like to learn how the whole GUI stuff is working so I try to understand it step by step...
      First of all I created a GUI with a single button. My goal is to activate an infinite while loop as soon as the checkbox is checked and to deactive the infinite while loop as soon as I uncheck the checkbox, but I don't understand how... I read various threads but couldn't find a good example etc...
      Thanks in advance 
    • Terenz
      By Terenz
      Hello,
      I have searched everywhere but on the forum there isn't an example of a combobox with checkbox. I think is a very useful control but require subclassing. Several example in C++, one of this:
      CheckComboBox Control
      If somone has some time to check it out. If need i can provide the source code. Thanks
    • ur
      By ur
      I have below screen when I launch the application.

      By default the first radio button is checked.
      I want to select the second radio button as highlighted.
      And when it is selected, the textbox highlighted will be enabled and we need to enter the license details.
       
      To do that, I tried to get the control id with windo info tool , but I am getting the second section(Concurrent Licenses) completely as "Button" class with ID 12.But not that radiobutton ID.
      Even I tried with that as below.
      $hwd =WinWaitActivate("erwin Data Modeler Licensing","Acquire concurrent u") ControlCommand($hwd,"","[CLASS:Button; INSTANCE:12]","Check") But not working.
      Any suggestions please.