Sign in to follow this  
Followers 0
Robin

Inputbox Error

6 posts in this topic

Suddenly i have struck a BLANK!

Can anyone here help me with this?

$Value = InputBox("Testing", "Enter Http or IP Address", "","")

If $Value = @error = 0 Then

MsgBox(0, "Abort", "Aborting...", 1)

Else

RunWait(@ComSpec & ' /c ' & 'ping ""' & $Value & '"" > C:\test.txt', '', @SW_HIDE)

RunWait("notepad.exe c:\test.txt")

EndIf

I want the program to return an "Error" if "OK" was pressed with NO data in the box...At the moment i DO get the error when "Cancel" is clicked.

thx guys :P

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$Value = InputBox("Testing", "Enter Http or IP Address…", "", "")

If $Value = @error = 0 or StringLen($Value) < 1 Then
    MsgBox(0, "Abort", "Aborting...", 1)
Else
    RunWait(@ComSpec & ' /c ' & 'ping ""' & $Value & '"" > C:\test.txt', '', @SW_HIDE)
    RunWait("notepad.exe c:\test.txt")
EndIf

This seems to work for me :P

Edited by Skizmata

AutoIt changed my life.

Share this post


Link to post
Share on other sites

$Value = InputBox("Testing", "Enter Http or IP Address", "", "")

If $Value = @error = 0 or StringLen($Value) < 1 Then
    MsgBox(0, "Abort", "Aborting...", 1)
Else
    RunWait(@ComSpec & ' /c ' & 'ping ""' & $Value & '"" > C:\test.txt', '', @SW_HIDE)
    RunWait("notepad.exe c:\test.txt")
EndIf

This seems to work for me :P

Yeeeaaaahhhh....good thinking there...I'm going 2 use it....thanks a bunch :unsure:

Share this post


Link to post
Share on other sites

This

If $Value = @error = 0
is a poorly formatted line of code.

While it seems to be working, you shouldn't test the three values in that manner in a single line.

To see why this is poor form, run your example and enter "123" in the input.

It should pass according to your conditions but it fails.

If you want to test for @error, this would be better:

$Value = InputBox("Testing", "Enter Http or IP Address &", "", "")
If @error <> 0  OR StringLen($Value) < 1 Then
    MsgBox(0, "Abort", "Aborting...", 1)
Else
    RunWait(@ComSpec & ' /c ' & 'ping ""' & $Value & '"" > C:\test.txt', '', @SW_HIDE)
    RunWait("notepad.exe c:\test.txt")
EndIf

This tests for @error 1st, then tests the string length.

Other way around is:

$Value = InputBox("Testing", "Enter Http or IP Address&", "", "")

If @error = 0 AND StringLen($Value) > 0 Then
    RunWait(@ComSpec & ' /c ' & 'ping ""' & $Value & '"" > C:\test.txt', '', @SW_HIDE)
    RunWait("notepad.exe c:\test.txt")
Else
    MsgBox(0, "Abort", "Aborting...", 1)
EndIf

Share this post


Link to post
Share on other sites

This

If $Value = @error = 0
is a poorly formatted line of code.

While it seems to be working, you shouldn't test the three values in that manner in a single line.

To see why this is poor form, run your example and enter "123" in the input.

It should pass according to your conditions but it fails.

If you want to test for @error, this would be better:

$Value = InputBox("Testing", "Enter Http or IP Address &", "", "")
If @error <> 0  OR StringLen($Value) < 1 Then
    MsgBox(0, "Abort", "Aborting...", 1)
Else
    RunWait(@ComSpec & ' /c ' & 'ping ""' & $Value & '"" > C:\test.txt', '', @SW_HIDE)
    RunWait("notepad.exe c:\test.txt")
EndIf

This tests for @error 1st, then tests the string length.

Other way around is:

$Value = InputBox("Testing", "Enter Http or IP Address&", "", "")

If @error = 0 AND StringLen($Value) > 0 Then
    RunWait(@ComSpec & ' /c ' & 'ping ""' & $Value & '"" > C:\test.txt', '', @SW_HIDE)
    RunWait("notepad.exe c:\test.txt")
Else
    MsgBox(0, "Abort", "Aborting...", 1)
EndIf
Aaa ok...got it, thanks.

Just for interrest sakes...Is there a way to make the InputBox "case-sensitive"?

Share this post


Link to post
Share on other sites

Aaa ok...got it, thanks.

Just for interrest sakes...Is there a way to make the InputBox "case-sensitive"?

Case sensitive string comparisons are like so using a double = .

$var = "Lawl"
$var2 = "LAWL"

If ( $var == $var2 ) then
 MsgBox(0, "", "Not equal")
else
MsgBox(0, "", "equal")
EndiF

Share this post


Link to post
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
Sign in to follow this  
Followers 0