Pook Posted February 11, 2011 Share Posted February 11, 2011 Long story short: i have a script that creates a task based off the host name you input. (Easy right) We'll on of the support guys ran this script on a Production box. (Not good) I've been asked to make the script Dummy proof. All of the Production boxs start with PRO-XXXXX, and the Test boxs start with TST-XXXXXX. My question is what does everyone think would be the best way to check if the name that was inputted doesn't start with "PRO-", and if it does I'm going to make it pop up a box saying. " Watch what your doing Dumb-A$$" =) Link to comment Share on other sites More sharing options...
Rogue5099 Posted February 11, 2011 Share Posted February 11, 2011 (edited) Local $Hostname = InputBox("Input", "Host Name") If StringInStr($Hostname, "PRO-") Then MsgBox(0, "Error", "Watch what your doing Dumb-A$$ =)") Exit EndIf Keep asking until not PRO- While 1 If CheckInput() <> 1 Then ExitLoop WEnd MsgBox(0, "Success", "String not PRO-") Func CheckInput() Local $Hostname = InputBox("Input", "Host Name") If StringInStr($Hostname, "PRO-") Then MsgBox(0, "Error", "Watch what your doing Dumb-A$$ =)") Return 1 EndIf Return 0 EndFunc Or to Restart your program: Local $Hostname = InputBox("Input", "Host Name") If StringInStr($Hostname, "PRO-") Then MsgBox(0, "Error", "Watch what your doing Dumb-A$$ =)") _restart() EndIf ; Restart your program ; Author UP_NORTH Func _restart() If @Compiled = 1 Then Run( FileGetShortName(@ScriptFullPath)) Else Run( FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc Edited February 11, 2011 by rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
Pook Posted February 11, 2011 Author Share Posted February 11, 2011 Thanks!!!!!!! After I update this one, I'm going to do the same thing for the rest. That way I never have to explain why something was done wrong to my director again! (I hope) 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