FTPMonster Posted January 11, 2006 Share Posted January 11, 2006 First off, I jut want to say that I love AutoIt. I just found it a few weeks ago and I'm never going back. Second, I have what's probably a noobie type question. Background: I want to use a GUI to provide user input into a big ole script I'm working on. I'm trying to provide some data validation (IP address numbers under 255. computername that's nothing but numbers and letters, etc). I have the GUI set up, but if there's a problem I just want it to send up a msgbox saying what's wrong, then pop back into the GUI instead of exiting. Here's what I have so far: expandcollapse popup#include <GUIConstants.au3> GUICreate("ADS Install Script setup", @desktopwidth/2, @desktopheight/2, 10, 10, -1) GUICtrlSetState(-1,$GUI_ACCEPTFILES) Opt("GUICoordMode",1) GUICtrlCreateLabel ("Please Enter the server name. It must be less than 11 characters and only contain letters or numbers. Default will be SERVER001", 10, 30, ((@desktopwidth/2)-10), 30) ; $servername = GUICtrlCreateInput ("SERVER001", 10, 60, 300, 20) ; will not accept drag&drop files GUICtrlCreateLabel ("Please Enter the domain name. It must be less than 11 characters and only contain letters or numbers. Default will be MYDOMAIN", 10, 80, ((@desktopwidth/2)-10), 30) ; $domainname = GUICtrlCreateInput ("MYDOMAIN", 10, 110, 300, 20) ; will not accept drag&drop files GUICtrlCreateLabel ("Enter the IP address. Default is 192.168.101.10. NOTE: Please choose a Class C address scheme. Choice of address might adversely affect DHCP scope. Please leave last octet below 100, but do not use 1.", 10, 130, ((@desktopwidth/2)-10), 30) ; $octet1 = GUICtrlCreateInput ("192", 10, 160, 40, 20) GUICtrlCreateLabel (".", 50, 160, 10, 20) $octet2 = GUICtrlCreateInput ("168", 60, 160, 40, 20) GUICtrlCreateLabel (".", 100, 160, 10, 20) $octet3 = GUICtrlCreateInput ("101", 110, 160, 40, 20) GUICtrlCreateLabel (".", 150, 160, 10, 20) $octet4 = GUICtrlCreateInput ("10", 160, 160, 40, 20) ;Opt("GUICoordMode",1) GUICtrlCreateLabel ("Enter the administrator's password. This will also be used for Active Directory Restore Mode. Default is P@ssw0rd. When you type, it will NOT put in asterisks so you can confirm what you type", 10, 180, ((@desktopwidth/2)-10), 30) ; $adminpw = GUICtrlCreateInput ("P@ssw0rd", 10, 210, 200, 20) ; will not accept drag&drop files GUICtrlCreateLabel ("Password Rules: Contains at least six characters."&@LF&"Contains characters from three of the following four categories:"&@LF&"Uppercase alphabet characters (AZ)"&@LF&"Lowercase alphabet characters (az)"&@LF&"Arabic numerals (09)"&@LF&"Nonalphanumeric characters (for example, !$#,%)", 10, 240, ((@desktopwidth/2)-10), 120) ; $btn = GUICtrlCreateButton ("Ok", 290, 375, 60, 20) GUISetState (@SW_SHOW) $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $btn exitloop EndSelect Wend ;checker ; Server Name $var001 = StringIsAlnum((GUICtrlRead($servername))) if stringlen((GUICtrlRead($servername))) < 11 and $var001 = 1 then MsgBox(4096, "len", "passed len") else MsgBox(4096, "fail", "There was a problem with the server name. Please correct it") endif ; Domain Name $var002 = StringIsAlnum((GUICtrlRead($domainname))) if stringlen((GUICtrlRead($domainname))) < 11 and $var002 = 1 then MsgBox(4096, "len", "passed len") else MsgBox(4096, "fail", "There was a problem with the domain name. Please correct it") endif ; octet1 $var003 = StringIsdigit((GUICtrlRead($octet1))) if (GUICtrlRead($octet1)) < 255 and $var003 = 1 then MsgBox(4096, "len", "passed number") else MsgBox(4096, "fail", "There was a problem with the First octet. Please correct it") endif ; octet2 $var004 = StringIsdigit((GUICtrlRead($octet2))) if (GUICtrlRead($octet2)) < 255 and $var004 = 1 then MsgBox(4096, "len", "passed number") else MsgBox(4096, "fail", "There was a problem with the Second octet. Please correct it") endif ; octet1 $var005 = StringIsdigit((GUICtrlRead($octet3))) if stringlen((GUICtrlRead($octet3))) < 255 and $var005 = 1 then MsgBox(4096, "len", "passed number") else MsgBox(4096, "fail", "There was a problem with the Third octet. Please correct it") endif ; octet1 $var006 = StringIsdigit((GUICtrlRead($octet1))) if stringlen((GUICtrlRead($octet4))) < 255 and $var006 = 1 then MsgBox(4096, "len", "passed number") else MsgBox(4096, "fail", "There was a problem with the Fourth octet. Please correct it") endif I'm sure it's related to how I do the validation, but I can't wrap my brain around how to fix this. Link to comment Share on other sites More sharing options...
Sokko Posted January 11, 2006 Share Posted January 11, 2006 It looks like you want to take that entire block under the WEnd statement and stick it all under the Case statement. Then add a "ContinueLoop" instruction under each "fail" message box. Keep the ExitLoop at the very end, of course, unless you want to keep the GUI open for something else. 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