Skizmata Posted October 10, 2007 Share Posted October 10, 2007 (edited) I use this constantly in my work I hope someone else can benefit from it. Helpful input appreciated. expandcollapse popup;=============================================================================== ; ; Description: Supplys a input box with optinal string regular expression and ; error message descriptor. ; Parameters: $sInputTitle - InputBox() Title ; $sInputPrompt - InputBox() Prompt ; $sStringRegExp - The String Regular Expression to check input aginst. ; Optinal Parameters: ; $sErrorTitle - Title of error box if string regular expression not met. ; $sErrorPrompt - Prompt of error box if string regular expression not met. ; $sDefault - The inputbox default text. (See InputBox() for more information) ; $sPasswordChar - Password mask char. (See InputBox() for more information) ; $iWidth - Width of InputBox() (See InputBox() for more information) ; $iHeight - Hight of InputBox() (See InputBox() for more information) ; $iLeft - Left location of InputBox() (See InputBox() for more information) ; $iTop - Top location of InputBox() (See InputBox() for more information) ; $iTimeOut - InputBox() timeout parameter. (See InputBox() for more information) ; Requirements: None ; Return Value: Value of InputBox ; Author: Skizmata ; Notes: First revision 10-2-07 ; ;=============================================================================== Func _InputPerStrRegExp($sInputTitle,$sInputPrompt,$sStringRegExp,$sErrorTitle = "Input Error",$sErrorPrompt = "Input invalid, please give input in standard format.",$sDefault = "",$sPasswordChar = "",$iWidth = -1,$iHeight = -1,$iLeft = Default,$iTop = Default,$iTimeOut = -1) While 1 $sInputReturn = InputBox($sInputTitle,$sInputPrompt,$sDefault,$sPasswordChar,$iWidth,$iHeight,$iLeft,$iTop,$iTimeOut) If @error Then SetError(@error) Return EndIf If StringRegExp($sInputReturn,$sStringRegExp) Then Return $sInputReturn Else MsgBox(16,$sErrorTitle,$sErrorPrompt) EndIf WEnd EndFunc P.S. I couldn't get the AutoIt tag button to work... Edited May 10, 2011 by Skizmata AutoIt changed my life. Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted October 10, 2007 Share Posted October 10, 2007 Good job!Since your dealing with regexp alot heres something that might interest you: http://www.autoitscript.com/forum/index.ph...5&hl=regexphttp://www.autoitscript.com/forum/index.ph...0&hl=regexp Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
Skizmata Posted October 10, 2007 Author Share Posted October 10, 2007 Thanks Revoked good stuff, I'm just getting into the wide world of SREs previously I had been using long winded If's. This is actually my first attempt at a properly formated UDF so any pointers on how to make it better functionally or better suited to the accepted standards of UDFs here would be fantastic. AutoIt changed my life. 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