Joel Posted March 17, 2005 Share Posted March 17, 2005 Hi all, I'm having problems creating an If > Else statement with regards to GUICtrlRead. If the input line is completely empty and a user hits submit, it should return an error. I'm pre-filling out the input line with the following: Global $fw1 = GuiCtrlRead ($tab0fileinp) If $fw1 = "~filename.au3" Then MsgBox(0, "Error: Missing File Information", "You need to specify a filename before submitting.") Else $opts = 1 MsgBox(0, "Continue Hit", "continuing file") Endif The $tab0fileinp is basically a GUICtrlCreateInput line with a pre-filled ~filename.au3. The user basically fills in their own filename.au3 and clicks submit. I'm checking against the ~filename.au3 and an empty input control. If the input box is empty, the user shouldn't be able to submit and create a file. So, how do I test against an empty input control? I tried isstring("") and "", but then it returns anything. Thanks, [font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font] Link to comment Share on other sites More sharing options...
Joel Posted March 17, 2005 Author Share Posted March 17, 2005 Also, if you want to see what I'm starting to do, compile the code below and run the application. I'm creating a fully functional autoit script creation utility which hand holds the user and allows them to create scripts step by step. If you take a look at it, you'll see where it's going. It's very very basic and just in the works but it will create the entire script, including basic information, autoit set options, globals, functions, etc. I'm still a long way away but I'm working on it because I wanted to speed up the script creation process. Hopefully, someone will find it useful. If you see or have advice on how I should limit code, or go about separating the script (it will be gigantic when I'm finished with it), let me know. Otherwise, just need help with one portion above in the first script. Thanks, expandcollapse popup#include <GUIConstants.au3> GUICreate ("Opti-Bot", 700, 600) GUISetFont (9, 330) Global $textcol = "0x253E5D" Global $opts = 0; Options Default Global $tab = GUICtrlCreateTab (0, 0, 700, 600) ;******** Tab Zero ************************************************************** Global $tab0 = GUICtrlCreateTabitem ("Start") GUICtrlSetState (-1, $GUI_SHOW) GUICtrlCreateGroup ("Create a new script", 10, 50, 430, 160) GUICtrlCreateLabel ("If this is your first time using this utility, read the help file by pressing (F1) at", 20, 70, 410, 20) GUICtrlCreateLabel ("anytime. Making a new script can be daunting, but with patience and ", 20, 85, 410, 20) GUICtrlCreateLabel ("guidance you will be making new scripts with relative ease. In order to start", 20, 100, 410, 20) GUICtrlCreateLabel ("creating a script, we need to take care of some basics first.", 20, 115, 410, 20) GUICtrlCreateLabel ("With all scripts, you should input basic information that relates version,", 20, 145, 410, 20) GUICtrlCreateLabel ("language, platform, author, and functional descriptions to tell the user", 20, 160, 410, 20) GUICtrlCreateLabel ("what the script is being used for. So, let's do that now.", 20, 175, 410, 20) ;End Intro GUICtrlCreateLabel ("AutoIt Version:", 120, 250, 100, 20) Global $tab0infoinp = GUICtrlCreateInput ("Version Number", 260, 250, 250, 20) GUICtrlCreateLabel ("Language:", 120, 270, 100, 20) Global $tab0infoinp1 = GUICtrlCreateInput ("English", 260, 270, 250, 20) GUICtrlCreateLabel ("Platform:", 120, 290, 100, 20) Global $tab0infoinp2 = GUICtrlCreateInput ("Windows 2000", 260, 290, 250, 20) GUICtrlCreateLabel ("Author:", 120, 310, 100, 20) Global $tab0infoinp3 = GUICtrlCreateInput ("Your Name", 260, 310, 250, 20) GUICtrlCreateLabel ("Email Address:", 120, 330, 100, 20) Global $tab0infoinp4 = GUICtrlCreateInput ("email@address.com", 260, 330, 250, 20) GUICtrlCreateLabel ("Script Function:", 120, 350, 100, 20) Global $tab0infoinp5 = GUICtrlCreateInput ("Place script description here", 260, 350, 250, 70) Global $tab0fileinp = GUICtrlCreateInput ("~filename.au3", 260, 430, 100, 20) Global $tab0infosub = GUICtrlCreateButton ("Submit", 368, 430, 70, 20) ;******* Tab One ***************************************************************** Global $tab1 = GUICtrlCreateTabitem ("Options") GUICtrlCreateGroup ("Autoit Default Options", 10, 50, 430, 520) GUICtrlCreateLabel ("Include", 15, 80, 150, 15) Global $tab1radopt1 = GUICtrlCreateRadio ("CaretCoordMode", 27, 100, 150, 20) Global $tab1radinp1 = GUICtrlCreateInput ("1", 200, 100, 100, 17) Global $tab1radbut1 = GUICtrlCreateButton ("Set", 330, 100, 40, 17) Global $tab1radinfo1 = GUICtrlCreateButton ("Info", 390, 100, 40, 17) Global $tab1radopt2 = GUICtrlCreateRadio ("ColorMode", 27, 117, 150, 20) Global $tab1radinp2 = GUICtrlCreateInput ("0", 200, 117, 100, 17) Global $tab1radbut2 = GUICtrlCreateButton ("Set", 330, 117, 40, 17) Global $tab1radinfo2 = GUICtrlCreateButton ("Info", 390, 117, 40, 17) Global $tab1radopt3 = GUICtrlCreateRadio ("ExpandEnvStrings", 27, 134, 150, 20) Global $tab1radinp3 = GUICtrlCreateInput ("0", 200, 134, 100, 17) Global $tab1radbut3 = GUICtrlCreateButton ("Set", 330, 134, 40, 17) Global $tab1radinfo3 = GUICtrlCreateButton ("Info", 390, 134, 40, 17) Global $tab1radopt4 = GUICtrlCreateRadio ("ExpandVarStrings", 27, 151, 150, 20) Global $tab1radinp4 = GUICtrlCreateInput ("0", 200, 151, 100, 17) Global $tab1radbut4 = GUICtrlCreateButton ("Set", 330, 151, 40, 17) Global $tab1radinfo4 = GUICtrlCreateButton ("Info", 390, 151, 40, 17) Global $tab1radopt5 = GUICtrlCreateRadio ("FtpBinaryMode", 27, 168, 150, 20) Global $tab1radinp5 = GUICtrlCreateInput ("1", 200, 168, 100, 17) Global $tab1radbut5 = GUICtrlCreateButton ("Set", 330, 168, 40, 17) Global $tab1radinfo5 = GUICtrlCreateButton ("Info", 390, 168, 40, 17) Global $tab1radopt6 = GUICtrlCreateRadio ("GUICoordMode", 27, 185, 150, 20) Global $tab1radinp6 = GUICtrlCreateInput ("1", 200, 185, 100, 17) Global $tab1radbut6 = GUICtrlCreateButton ("Set", 330, 185, 40, 17) Global $tab1radinfo6 = GUICtrlCreateButton ("Info", 390, 185, 40, 17) Global $tab1radopt7 = GUICtrlCreateRadio ("GUIOnEventMode", 27, 202, 150, 20) Global $tab1radinp7 = GUICtrlCreateInput ("0", 200, 202, 100, 17) Global $tab1radbut7 = GUICtrlCreateButton ("Set", 330, 202, 40, 17) Global $tab1radinfo7 = GUICtrlCreateButton ("Info", 390, 202, 40, 17) Global $tab1radopt8 = GUICtrlCreateRadio ("GUIResizeMode", 27, 219, 150, 20) Global $tab1radinp8 = GUICtrlCreateInput ("0", 200, 219, 100, 17) Global $tab1radbut8 = GUICtrlCreateButton ("Set", 330, 219, 40, 17) Global $tab1radinfo8 = GUICtrlCreateButton ("Info", 390, 219, 40, 17) Global $tab1radopt9 = GUICtrlCreateRadio ("MouseClickDelay", 27, 236, 150, 20) Global $tab1radinp9 = GUICtrlCreateInput ("10", 200, 236, 100, 17) Global $tab1radbut9 = GUICtrlCreateButton ("Set", 330, 236, 40, 17) Global $tab1radinfo9 = GUICtrlCreateButton ("Info", 390, 236, 40, 17) Global $tab1radopt10 = GUICtrlCreateRadio ("MouseClickDownDelay", 27, 253, 150, 20) Global $tab1radinp10 = GUICtrlCreateInput ("10", 200, 253, 100, 17) Global $tab1radbut10 = GUICtrlCreateButton ("Set", 330, 253, 40, 17) Global $tab1radinfo10 = GUICtrlCreateButton ("Info", 390, 253, 40, 17) Global $tab1radopt11 = GUICtrlCreateRadio ("MouseClickDragDelay", 27, 270, 150, 20) Global $tab1radinp11 = GUICtrlCreateInput ("250", 200, 270, 100, 17) Global $tab1radbut11 = GUICtrlCreateButton ("Set", 330, 270, 40, 17) Global $tab1radinfo11 = GUICtrlCreateButton ("Info", 390, 270, 40, 17) Global $tab1radopt12 = GUICtrlCreateRadio ("MouseCoordMode", 27, 287, 150, 20) Global $tab1radinp12 = GUICtrlCreateInput ("1", 200, 287, 100, 17) Global $tab1radbut12 = GUICtrlCreateButton ("Set", 330, 287, 40, 17) Global $tab1radinfo12 = GUICtrlCreateButton ("Info", 390, 287, 40, 17) Global $tab1radopt13 = GUICtrlCreateRadio ("MustDeclareVars", 27, 304, 150, 20) Global $tab1radinp13 = GUICtrlCreateInput ("0", 200, 304, 100, 17) Global $tab1radbut13 = GUICtrlCreateButton ("Set", 330, 304, 40, 17) Global $tab1radinfo13 = GUICtrlCreateButton ("Info", 390, 304, 40, 17) Global $tab1radopt14 = GUICtrlCreateRadio ("OnExitFunc", 27, 321, 150, 20) Global $tab1radinp14 = GUICtrlCreateInput ("OnAutoItExit", 200, 321, 100, 17) Global $tab1radbut14 = GUICtrlCreateButton ("Set", 330, 321, 40, 17) Global $tab1radinfo14 = GUICtrlCreateButton ("Info", 390, 321, 40, 17) Global $tab1radopt15 = GUICtrlCreateRadio ("PixelCoordMode", 27, 338, 150, 20) Global $tab1radinp15 = GUICtrlCreateInput ("1", 200, 338, 100, 17) Global $tab1radbut15 = GUICtrlCreateButton ("Set", 330, 338, 40, 17) Global $tab1radinfo15 = GUICtrlCreateButton ("Info", 390, 338, 40, 17) Global $tab1radopt16 = GUICtrlCreateRadio ("RunErrorsFatal", 27, 355, 150, 20) Global $tab1radinp16 = GUICtrlCreateInput ("1", 200, 355, 100, 17) Global $tab1radbut16 = GUICtrlCreateButton ("Set", 330, 355, 40, 17) Global $tab1radinfo16 = GUICtrlCreateButton ("Info", 390, 355, 40, 17) Global $tab1radopt17 = GUICtrlCreateRadio ("SendAttachMode", 27, 372, 150, 20) Global $tab1radinp17 = GUICtrlCreateInput ("0", 200, 372, 100, 17) Global $tab1radbut17 = GUICtrlCreateButton ("Set", 330, 372, 40, 17) Global $tab1radinfo17 = GUICtrlCreateButton ("Info", 390, 372, 40, 17) Global $tab1radopt18 = GUICtrlCreateRadio ("SendCapslockMode", 27, 389, 150, 20) Global $tab1radinp18 = GUICtrlCreateInput ("1", 200, 389, 100, 17) Global $tab1radbut18 = GUICtrlCreateButton ("Set", 330, 389, 40, 17) Global $tab1radinfo18 = GUICtrlCreateButton ("Info", 390, 389, 40, 17) Global $tab1radopt19 = GUICtrlCreateRadio ("SendKeyDelay", 27, 406, 150, 20) Global $tab1radinp19 = GUICtrlCreateInput ("5", 200, 406, 100, 17) Global $tab1radbut19 = GUICtrlCreateButton ("Set", 330, 406, 40, 17) Global $tab1radinfo19 = GUICtrlCreateButton ("Info", 390, 406, 40, 17) Global $tab1radopt20 = GUICtrlCreateRadio ("SendKeyDownDelay", 27, 423, 150, 20) Global $tab1radinp20 = GUICtrlCreateInput ("1", 200, 423, 100, 17) Global $tab1radbut20 = GUICtrlCreateButton ("Set", 330, 423, 40, 17) Global $tab1radinfo20 = GUICtrlCreateButton ("Info", 390, 423, 40, 17) Global $tab1radopt21 = GUICtrlCreateRadio ("TrayIconDebug", 27, 440, 150, 20) Global $tab1radinp21 = GUICtrlCreateInput ("0", 200, 440, 100, 17) Global $tab1radbut21 = GUICtrlCreateButton ("Set", 330, 440, 40, 17) Global $tab1radinfo21 = GUICtrlCreateButton ("Info", 390, 440, 40, 17) Global $tab1radopt22 = GUICtrlCreateRadio ("TrayIconHide", 27, 457, 150, 20) Global $tab1radinp22 = GUICtrlCreateInput ("0", 200, 457, 100, 17) Global $tab1radbut22 = GUICtrlCreateButton ("Set", 330, 457, 40, 17) Global $tab1radinfo22 = GUICtrlCreateButton ("Info", 390, 457, 40, 17) Global $tab1radopt23 = GUICtrlCreateRadio ("WinDetectHiddenText", 27, 474, 150, 20) Global $tab1radinp23 = GUICtrlCreateInput ("0", 200, 474, 100, 17) Global $tab1radbut23 = GUICtrlCreateButton ("Set", 330, 474, 40, 17) Global $tab1radinfo23 = GUICtrlCreateButton ("Info", 390, 474, 40, 17) Global $tab1radopt24 = GUICtrlCreateRadio ("WinSearchChildren", 27, 491, 150, 20) Global $tab1radinp24 = GUICtrlCreateInput ("0", 200, 491, 100, 17) Global $tab1radbut24 = GUICtrlCreateButton ("Set", 330, 491, 40, 17) Global $tab1radinfo24 = GUICtrlCreateButton ("Info", 390, 491, 40, 17) Global $tab1radopt25 = GUICtrlCreateRadio ("WinTextMatchMode", 27, 508, 150, 20) Global $tab1radinp25 = GUICtrlCreateInput ("1", 200, 508, 100, 17) Global $tab1radbut25 = GUICtrlCreateButton ("Set", 330, 508, 40, 17) Global $tab1radinfo25 = GUICtrlCreateButton ("Info", 390, 508, 40, 17) Global $tab1radopt26 = GUICtrlCreateRadio ("WinTitleMatchMode", 27, 525, 150, 20) Global $tab1radinp26 = GUICtrlCreateInput ("1", 200, 525, 100, 17) Global $tab1radbut26 = GUICtrlCreateButton ("Set", 330, 525, 40, 17) Global $tab1radinfo26 = GUICtrlCreateButton ("Info", 390, 525, 40, 17) Global $tab1radopt27 = GUICtrlCreateRadio ("WinWaitDelay", 27, 542, 150, 20) Global $tab1radinp27 = GUICtrlCreateInput ("250", 200, 542, 100, 17) Global $tab1radbut27 = GUICtrlCreateButton ("Set", 330, 542, 40, 17) Global $tab1radinfo27 = GUICtrlCreateButton ("Info", 390, 542, 40, 17) GUICtrlCreateGroup ("", -99, -99, 1, 1) ;close group ;******** Tab Two **************************************************************** Global $tab3 = GUICtrlCreateTabitem ("Globals") ;******** Tab Three ************************************************************** Global $tab4 = GUICtrlCreateTabitem ("Functions") GUICtrlCreateTabitem ("") ; end tabitem definition GuiSetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg () If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $tab0infosub Then _filewrite() Wend Func _filewrite() Global $fw1 = GuiCtrlRead ($tab0fileinp) Dim $fw2 = GuiCtrlRead ($tab0infoinp) Dim $fw3 = GuiCtrlRead ($tab0infoinp1) Dim $fw4 = GuiCtrlRead ($tab0infoinp2) Dim $fw5 = GuiCtrlRead ($tab0infoinp3) Dim $fw6 = GuiCtrlRead ($tab0infoinp4) Dim $fw7 = GuiCtrlRead ($tab0infoinp5) If $fw1 = "~filename.au3" Then MsgBox(0, "Error: Missing File Information", "You need to specify a filename before submitting.") Else $opts = 1 MsgBox(0, "Continue Hit", "continuing file") FileOpen($fw1, 2) FileWrite($fw1, "; ----------------------------------------------------------------------------" & @CRLF) FileWrite($fw1, ";" & @CRLF) FileWrite($fw1, "; AutoIt Version: " & $fw2 & @CRLF) FileWrite($fw1, "; Language: " & $fw3 & @CRLF) FileWrite($fw1, "; Platform: " & $fw4 & @CRLF) FileWrite($fw1, "; Author: " & $fw5 & " <" & $fw6 & ">" & @CRLF) FileWrite($fw1, ";" & @CRLF) FileWrite($fw1, "; Script Function:" & @CRLF) FileWrite($fw1, "; " & $fw7 & @CRLF) FileWrite($fw1, ";" & @CRLF) FileWrite($fw1, "; ----------------------------------------------------------------------------" & @CRLF) FileWrite($fw1, "" & @CRLF) FileWrite($fw1, "" & @CRLF) FileWrite($fw1, "; ----------------------------------------------------------------------------" & @CRLF) FileWrite($fw1, "; Set up defaults listed below.." & @CRLF) FileWrite($fw1, "; ----------------------------------------------------------------------------" & @CRLF) FileWrite($fw1, "" & @CRLF) EndIf EndFunc ;==>_filewrite Func _options() Dim $opt1 = "AutoItSetOption(""MustDeclareVars"", 1)" FileWrite($fw1, $opt1 & @CRLF) EndFunc ;==>_options [font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font] Link to comment Share on other sites More sharing options...
steveR Posted March 17, 2005 Share Posted March 17, 2005 (edited) i just added what you see below and it worked for me Global $fw1 = GuiCtrlRead ($tab0fileinp) If $fw1 = "~filename.au3" or $fw1 ="" Then MsgBox(0, "Error: Missing File Information", "You need to specify a filename before submitting.") Else $opts = 1 MsgBox(0, "Continue Hit", "continuing file") Endif EDIT: Looks cool so far. Hope you get it working the way you want. Also I was thinking maybe there is a way to put the controls in an array. And maybe as you get each function working the way you want, put it in a seperate file and #include it. It might make things easier to work with than one huge file. Edited March 17, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass. Link to comment Share on other sites More sharing options...
Joel Posted March 17, 2005 Author Share Posted March 17, 2005 Bah I had that believe it or not except when doing the or portion I forgot to include $fw1 = "". Instead I had if $fw1 = "~filename.au3" or "" then .. Thanks for the clarification. I've been thinking about how I want to format the file. I definitely think using arrays will help out immensely and I'm going to put the functions in include files so that they are easier to manage. Thanks! [font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font] 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