Jump to content

[Solved] Built Error Checking


Recommended Posts

I'm wanting to build in some error checking to my GUI and so far I have been able to check to see if one check box is unchecked and if the right input has been entered but what I can't seem to nail down is how to just check if all 3 check boxes are not checked. Here is the code that I have so far.

#include <GUIConstants.au3>
#include <IE.au3>

GUICreate("Drivers/Manuals/Warranty", 280, 110)

$Driver = GUICtrlCreateCheckbox("Drivers", 10, 10)
GUICtrlSetState(-1, $GUI_CHECKED)
$Manual = GUICtrlCreateCheckbox("Manual", 80, 10)
$Warranty = GUICtrlCreateCheckbox("Warranty", 150, 10)
GUICtrlCreateLabel("Service Tag #:", 10, 45)
$Input = GUICtrlCreateInput("", 90, 40)
GUICtrlSetState(-1, $GUI_FOCUS)
$Submit = GUICtrlCreateButton("Submit", 40, 70, 50)
$Exit = GUICtrlCreateButton("Cancel", 150, 70, 50)

Local $aAccelKeys[1][2] = [["{ENTER}", $Submit]]
GUISetAccelerators($aAccelKeys)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
Case $msg = $Submit
$CBStatus = GUICtrlRead($Driver)
If $CBStatus = $GUI_UNCHECKED Then
  MsgBox(0, "Error", "Pleaes make a selection first")
            $serv_tag = GUICtrlRead($Input)
  if not StringRegExp($serv_tag, "^([a-zA-Z0-9]{4}|[a-zA-Z0-9]{6})1$") Then
  MsgBox(0, "Error", "Service tag must be 5 or 7 alphanumeric characters and end with 1!")
  Else
            If IsChecked($Driver) Then _Fire($serv_tag)
If IsChecked($Manual) Then _Fire2($serv_tag)
If IsChecked($Warranty) Then _Fire3($serv_tag)
ExitLoop
EndIf
        Case $msg = $Exit
            ExitLoop
    EndSelect
WEnd

Exit 0

Func _Fire($sServiceTag)
   $oIE = _IECreate("http://www.dell.com/support/drivers/us/en/04/DriversHome/NeedProductSelection",0 ,1 ,0)
EndFunc

Func _Fire2($sServiceTag)
   $oIE = _IECreate("http://support.dell.com/support/topics/global.aspx/support/my_systems_info/manuals?c=us&l=en&s=biz&~ck=ln&lnki=0&ServiceTag=" & $sServiceTag, 0, 1, 0)
EndFunc

Func _Fire3($sServiceTag)
   $oIE = _IECreate("http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&cs=555&l=en&s=biz&~ck=anavml&ServiceTag=" & $sServiceTag, 0, 1, 0)
EndFunc

Func IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

Any advice would be wonderful.

Edited by Crazyace

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Link to comment
Share on other sites

Try:

If Not IsChecked($Driver) And Not IsChecked($Manual) And Not IsChecked($Warranty) Then
...
EndIf

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Link to comment
Share on other sites

Try:

If Not IsChecked($Driver) And Not IsChecked($Manual) And Not IsChecked($Warranty) Then
...
EndIf

Thanks I didn't think about the "And Not" I had tried something like that before. Seems that I have a case issue now.

While 1
   $msg = GUIGetMsg()
   Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Submit
$serv_tag = GUICtrlRead($Input)
If Not IsChecked($Driver) And Not IsChecked($Manual) And Not IsChecked($Warranty) Then
  MsgBox(0, "Error", "Pleaes make a selection first")
if not StringRegExp($serv_tag, "^([a-zA-Z0-9]{4}|[a-zA-Z0-9]{6})1$") Then
  MsgBox(16, "Error", "Service tag must be 5 or 7 alphanumeric characters and end with 1!")
  Else
If IsChecked($Driver) Then _Fire($serv_tag)
If IsChecked($Manual) Then _Fire2($serv_tag)
If IsChecked($Warranty) Then _Fire3($serv_tag)
  ExitLoop
EndIf
Case $msg = $Exit
ExitLoop
   EndSelect
WEnd

The error is "==> "Case" statement with no matching "Select"or "Switch" statement.: Case $msg = $Exit"

Edited by Crazyace

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Link to comment
Share on other sites

Here:

While 1
$msg = GUIGetMsg()
Select
  Case $msg = $GUI_EVENT_CLOSE Or $msg = $Exit
   ExitLoop
  Case $msg = $Submit
   $serv_tag = GUICtrlRead($Input)
   If Not IsChecked($Driver) And Not IsChecked($Manual) And Not IsChecked($Warranty) Then
    MsgBox(0, "Error", "Pleaes make a selection first")
   ElseIf Not StringRegExp($serv_tag, "^([a-zA-Z0-9]{4}|[a-zA-Z0-9]{6})1$") Then
    MsgBox(16, "Error", "Service tag must be 5 or 7 alphanumeric characters and end with 1!")
   Else
    If IsChecked($Driver) Then _Fire($serv_tag)
    If IsChecked($Manual) Then _Fire2($serv_tag)
    If IsChecked($Warranty) Then _Fire3($serv_tag)
    ExitLoop
   EndIf
EndSelect
WEnd

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Link to comment
Share on other sites

Here:

While 1
$msg = GUIGetMsg()
Select
  Case $msg = $GUI_EVENT_CLOSE Or $msg = $Exit
   ExitLoop
  Case $msg = $Submit
   $serv_tag = GUICtrlRead($Input)
   If Not IsChecked($Driver) And Not IsChecked($Manual) And Not IsChecked($Warranty) Then
    MsgBox(0, "Error", "Pleaes make a selection first")
   ElseIf Not StringRegExp($serv_tag, "^([a-zA-Z0-9]{4}|[a-zA-Z0-9]{6})1$") Then
    MsgBox(16, "Error", "Service tag must be 5 or 7 alphanumeric characters and end with 1!")
   Else
    If IsChecked($Driver) Then _Fire($serv_tag)
    If IsChecked($Manual) Then _Fire2($serv_tag)
    If IsChecked($Warranty) Then _Fire3($serv_tag)
    ExitLoop
   EndIf
EndSelect
WEnd

That's so much that works great. So, what did I break when I was adding my error checking if statements?

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...