Jump to content

Recommended Posts

Posted

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

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.

Posted

$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:
Posted

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
Posted

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"?

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...