arcticpup Posted November 14, 2008 Posted November 14, 2008 Hi all, I've been using AutoIT for a grand total of 2 days now, and my app is working pretty much as I want it too, but have a question. How can I get the cancel option of an inputbox to do something more useful than return a blank string? At the moment, I've added an IF statement to show a dialog box if it is returned as blank (And I'm dealing with registry entries and ini files here so writing a blank value would be a bad thing for me!) Any ideas? $var5 = InputBox("Data Paths", "Your current data path is shown below." & @LF & "Please type in the new path.", $var1 & "\Master.ini", " M254", "300", "") ;Check for blank inputs which are bad If $var5 = "" Then $msgcode = MsgBox(16 + 0, "ERROR", "Your data path can not be blank" & @LF & "Please correct this")
Andreik Posted November 14, 2008 Posted November 14, 2008 You can create your own function to work good for what you want to do.
arcticpup Posted November 14, 2008 Author Posted November 14, 2008 (edited) You can create your own function to work good for what you want to do. Eeek! I'm not that good! I'm not a programmer by trade! I've found a workaround by putting it into a permenant loop if cancel is pressed so it keeps taking you back to the input dialog, which is better than what I had If $var3 = "" Then do $msgcode = MsgBox(16 + 0, "Warning", "You need to update or accept your master data paths") $var3 = InputBox("Data Paths", "Please enter your new data path", $var1, " M254", "", "150") until $var3 <> "" An even better option would be to disable or remove the cancel button. Is this easier to acomplish? Edited November 14, 2008 by arcticpup
GEOSoft Posted November 14, 2008 Posted November 14, 2008 Not a good idea to prevent the user from being able to cancel something that they may have started by accident. Here is a method that will return an error if they press cancel and if they press ok and the input is blank then it simply calls the function again. ; $iVar = _Input() If NOT @Error Then MsgBox(0, "Results", $iVar) Else MsgBox(0, "Error", "Cancel was clicked or another error occured") EndIf Func _Input() $var5 = InputBox("Data Paths", "Your current data path is shown below." & @LF & "Please type in the new path.", $var1 & "\Master.ini", " M254", "300", "") While NOT @Error ;Check for blank inputs which are bad If $var5 = "" Then $msgcode = MsgBox(16 + 0, "ERROR", "Your data path can not be blank" & @LF & "Please correct this") _Input() Else Return $var5 EndIf Wend Return SetError(1) ;; This can be changed to Return SetError(@Error) to return the actual error. EndFunc ; George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
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