Thudo Posted August 13, 2010 Posted August 13, 2010 Trying to put a range where the user cannot input a value higher than X. In this case, any number less than 5 is not accepted. Local $iMinTime = 5 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; Read Timeout input $tidle = GUICtrlRead($timeidle) ; Check value If _CheckMinimumIdleTime($tidle, $iMinTime) = 0 Then $Error = "Timeout must be no less than 5 minutes: " $Error &= "Please change the time." MsgBox(48, "Error", $Error) GUICtrlSetData($timeidle, "") Return EndIf Func _CheckMinimumIdleTime($tidle, $iMinTime) Local $iResult = StringRegExp($tidle, $iMinTime) If @error = 0 Then Return SetError(0, 0, ($iResult <> 0)) Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_CheckMinimumIdleTimeHowever it only is accepting the value of 5. I need it to accept values 5 and greater and obviously nothing less than 5. Yeah I know this is likely stupid-easy. I've tried to create an array and switch/case for Local $iMinTime = 5 but that hasn't worked. As an FYI.. GUICtrlRead($timeidle) is when the user inputs the value to be checked.
Spiff59 Posted August 13, 2010 Posted August 13, 2010 You just need an edit like this? #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> Global $iMinTime = 5, $status GUICreate("") $TimeIdle = GUICtrlCreateInput("", 20, 10, 60) $btn = GUICtrlCreateButton("SET VALUE", 10, 40, 80, 18 ,$BS_DEFPUSHBUTTON) $message = GUICtrlCreateLabel("", 10, 70, 180, 16) GUISetState() While 1 $msg = GUIGetMsg() If $msg = -3 then Exit If $msg = $btn Then $status = _EditTimeIdle() If $status Then MsgBox(1,"","process the good value") $status = 0 EndIf WEnd Func _EditTimeIdle() Local $tidle = GUICtrlRead($TimeIdle) If $tidle < $iMinTime Then GUICtrlSetData($message, "VALUE MUST BE 5 OR GREATER") GUICtrlSetData($timeidle, "") GUICtrlSetState($timeidle, $GUI_FOCUS) Return Else GUICtrlSetData($message, "") EndIf Return $tidle EndFunc
Thudo Posted August 13, 2010 Author Posted August 13, 2010 (edited) Thanks Spiff but I only need detection code as I already have the GUI buttons already placed which link off GUICtrlRead($timeidle). You'll also notice I have prompt boxes coming up to tell the user whats invalid. Those must be maintained. Edited August 13, 2010 by Thudo
somdcomputerguy Posted August 13, 2010 Posted August 13, 2010 (Detection) code like this? If GUICtrlRead($timeidle) < $iMinTime Then $Error = "Timeout must be no less than 5 minutes: " $Error &= "Please change the time." MsgBox(48, "Error", $Error) GUICtrlSetData($timeidle, "") EndIf - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Thudo Posted August 13, 2010 Author Posted August 13, 2010 (edited) I think I need a twinkie.. I over-complicated the original script. Gah.. Where is Jason to Chainsaw me Texan stylez.. Thanks SOMD! Happy 13ths today to you. Final script: Local $iMinTime = 7 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; Read Timeout input $tidle = GUICtrlRead($timeidle) ; Check value If GUICtrlRead($timeidle) < $iMinTime then $Error = "Timeout must be no less than 7 minutes: " $Error &= "Please change the time." MsgBox(48, "Error", $Error) GUICtrlSetData($timeidle, "") Return EndIf Edited August 13, 2010 by Thudo
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