Jump to content

Error check implementation (problem with loop exit)


 Share

Recommended Posts

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!

Link to comment
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
 Share

×
×
  • Create New...