Jump to content

Recommended Posts

Posted

Hello, i have been using the forum a lot to make my script and so made an account.

Anyway, My Question is this.

Is there a function that will either give 0 or 1 to a inputbox/variable if it has characters/numbers in?

Is there a way to do it. Thanks in advance. :D

Posted

Cracked It! :D

For people wondering it is this.

$inputbox = GuiCtrlCreateInput("")
$userinput = GUICtrlRead ($inputbox)

if $userinput = "" Then
    MsgBox(0,"Error", "Please Enter Something!")
Else
DO something else!
EndIF
Posted (edited)

Is there a function that will either give 0 or 1 to a inputbox/variable if it has characters/numbers in?

You said characters/numbers in it?  :D

The question should be "check if inputbox/variable is empty or not?"

Your question is unclear.

Edit:typo

Edited by nfaustin
[font="Palatino Linotype"][size="2"]*** The information contained in this post should be considered and certified WORKS ON MY MACHINE ***[/size][/font][font="Palatino Linotype"][size="2"] [/size][/font]
Posted (edited)

You can force the InputBox function to require input using the Mandatory flag.

$sInput = InputBox("Enter a sentence.", "Testing", "", " M")
If @Error = 1 Then
   ; Cancel button was pressed.  By having the " M" flag at the end, you can not press the Ok button if there is no text.
Else
   ; At least one character is present in the variable.
Endif

If you want to check if any text is in a string, can use a comparison.

If $sCheck > "" Then
   ; You got stuff in it
Else
   ; It is empty.
EndIf

Edit: Simplified the second code block. That's what I get for coding when tired.

Edited by Nutster

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Posted

You said characters/numbers in it?  :D

The question should be "check if inputbox/variable is empty or not?"

BTW,

Based on my understanding on your original question,I used this to check if the inputbox/variable has characters/numbers in it.

MsgBox(0,'',GUICtrlRead(StringIsInt($userinput)))
[font="Palatino Linotype"][size="2"]*** The information contained in this post should be considered and certified WORKS ON MY MACHINE ***[/size][/font][font="Palatino Linotype"][size="2"] [/size][/font]
Posted (edited)

A colleague of mine who is not very javascript or for that matter jQuery aware asked me to help him to do a little trick with jQuery. He needed to select the contents of the input box when user selects it (when onfocus event is fired basically).

Edited by Valik
Posted

A colleague of mine who is not very javascript or for that matter jQuery aware asked me to help him to do a little trick with jQuery. He needed to select the contents of the input box when user selects it (when onfocus event is fired basically).

Ok!! So what has this got to do with this thread or with this forum or with AutoIT?

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
Posted (edited)

Ok!! So what has this got to do with this thread or with this forum or with AutoIT?

Notice that this jerk has been blocked. It is because he was off-topic (and more) on all his posts. Valik trimmed down his posts so they were only off-topic. Ignore him. Edited by Nutster

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

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
  • Recently Browsing   0 members

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