Travis Posted April 21, 2009 Share Posted April 21, 2009 (edited) Hi, I've just started learning to write Autoscript (having some "experience" with visual basic and liberty basic, if you consider the latter a "programming language"). I'm writing this little program that has a dialog with an input field, and when the user presses a button it will scan if the user has entered anything in the input and then a) create a msgbox and tell the user what they wrote just end if they entered nothing C) have it end if they just entered a space or multiple spaces. However, I have not worked out the code on the even that they enter spaces _and_ any other character. This is what I have If GUICTRLRead($input) >= Chr(32) Then The reason for >= is because I found out with just = it will only want to understand _1_ space :/ so >= is working for me. But if the user enters something before or after spaces it will run with this code. How could I fix this? I could probably spend all night writing spaghetti code but decided to ask here >_> Thanks in advance.. here is the so far code if you need it for reference. ;program demonstrates input boxes and msgboxes #include <GUIConstantsEx.au3> GUICreate("MsgBox Mkr",300,400) $button = GUICtrlCreateButton("Close",20,350,60) $input = GUICtrlCreateInput("",20,100,100,50) GUISetState(@SW_SHOW) While 1 dim $msg = GUIGetMsg() Select Case $msg = $button If GUICTRLRead($input) <> "" then If GUICTRLRead($input) >= Chr(32) Then MsgBox(0,"Hi","You said space, hehehe") Exit Else MsgBox(0,"Hi",GUICtrlRead($input)) Exit EndIf EndIf Exit Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Edited April 21, 2009 by Travis Link to comment Share on other sites More sharing options...
Authenticity Posted April 21, 2009 Share Posted April 21, 2009 Dim $sStr = ' ' ; 8) If StringRegExp($sStr, '^\s*$') Then ConsoleWrite('An empty input' & @LF) Else ConsoleWrite($sStr & @LF) EndIf Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 21, 2009 Moderators Share Posted April 21, 2009 Travis, Another way is to look at the first character of the input and see if it is a space:;program demonstrates input boxes and msgboxes #include <GUIConstantsEx.au3> GUICreate("MsgBox Mkr", 300, 400) $button = GUICtrlCreateButton("Close", 20, 350, 60) $input = GUICtrlCreateInput("", 20, 100, 100, 50) GUISetState(@SW_SHOW) While 1 Dim $msg = GUIGetMsg() Select Case $msg = $button $sInput = GUICtrlRead($input) ; <<<<<<<<<<<< read the input then use the result in the If statements If $sInput <> "" Then If StringLeft($sInput, 1) = Chr(32) Then MsgBox(0, "Hi", "You said space, hehehe") Exit Else MsgBox(0, "Hi", $sInput) Exit EndIf EndIf Exit Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Travis Posted April 21, 2009 Author Share Posted April 21, 2009 Thank you both for you replies! 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