Jump to content

a newb question


Recommended Posts

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 by Travis
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...