Muchuchu Posted April 26, 2008 Share Posted April 26, 2008 I've been making scripts just like this one for weeks for for some reason i can't get this function to compile. I want it to get the persons ip, then ping it, then have a message box rating how fast the ping was but when i use $time as the variable for the ping response time it doesn't work. expandcollapse popupfunc dowork() do $i = 0 $PublicIP = _GetIP() MsgBox(0, "IP Address", "Your IP Address is: " & $PublicIP) sleep("900") $time = ping($publicip) sleep("500") If $time < 1 then msgbox(1, "ULTRA FAST", "Your internet speed is top notch, it took in seconds:" & $time * .001) endif if $time < 2 and > 1 then msgbox(1, "GREAT", "Your internet speed is excellent, it took: " & $time * .001 "seconds") endif if $time < 3 and > 2 then msgbox(1, "Good", "Your internet speed is good, it took: " & $time * .001 "seconds") EndIf if $time < 4 and > 3 Then msgbox(1, "Fair", "Your internet speed is fair, it took: " & $time * .001 "seconds") EndIf if $time < 5 and > 4 Then msgbox(1, "Poor", "Your internet speed is poor, it took: " & $time * .001 "seconds") EndIf if $time > 6 Then msgbox(1, "Bad", "Your internet speed is bad, look to get new service, it took: " & $time * .001 "seconds") endif $i = $i + 1 until $i = 1 endfunc Link to comment Share on other sites More sharing options...
d4rk Posted April 26, 2008 Share Posted April 26, 2008 (edited) expandcollapse popupfunc dowork() do $i = 0 $PublicIP = _GetIP() MsgBox(0, "IP Address", "Your IP Address is: " & $PublicIP) sleep("900") $time = ping($publicip) sleep("500") If $time < 1 then msgbox(1, "ULTRA FAST", "Your internet speed is top notch, it took in seconds:" & $time * .001) endif if $time < 2 and $time > 1 then msgbox(1, "GREAT", "Your internet speed is excellent, it took: " & $time * .001 & "seconds") endif if $time < 3 and $time > 2 then msgbox(1, "Good", "Your internet speed is good, it took: " & $time * .001 & "seconds") EndIf if $time < 4 and $time > 3 Then msgbox(1, "Fair", "Your internet speed is fair, it took: " & $time * .001 & "seconds") EndIf if $time < 5 and $time > 4 Then msgbox(1, "Poor", "Your internet speed is poor, it took: " & $time * .001 & "seconds") EndIf if $time > 6 Then msgbox(1, "Bad", "Your internet speed is bad, look to get new service, it took: " & $time * .001 & "seconds") endif $i = $i + 1 until $i = 1 endfunc Wuhh, My internet speed is bad Edited April 26, 2008 by d4rk [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
Zed Posted April 26, 2008 Share Posted April 26, 2008 (edited) Isnt ping in milliseconds? Edited April 26, 2008 by Zed Link to comment Share on other sites More sharing options...
Muchuchu Posted April 26, 2008 Author Share Posted April 26, 2008 Thanks dark i knew it was something like that, it was annoying the heck out of me. I've yet to learn how redundant you have to be when programming, i'll get it sometime Link to comment Share on other sites More sharing options...
Swift Posted April 26, 2008 Share Posted April 26, 2008 A nicer, Cleaner version: Func dowork() $PublicIP = _GetIP() ToolTip("IP: " & $PublicIP) Sleep(1000) $time = Ping($PublicIP) Switch $time Case $time < 1 MsgBox(1, "ULTRA FAST", "Your internet speed is top notch, it took in seconds:" & $time * .001) Case $time < 2 And $time > 1 MsgBox(1, "GREAT", "Your internet speed is excellent, it took: " & $time * .001 & "seconds") Case $time < 3 And $time > 2 MsgBox(1, "Good", "Your internet speed is good, it took: " & $time * .001 & "seconds") Case $time < 4 And $time > 3 MsgBox(1, "Fair", "Your internet speed is fair, it took: " & $time * .001 & "seconds") Case $time < 5 And $time > 4 MsgBox(1, "Poor", "Your internet speed is poor, it took: " & $time * .001 & "seconds") Case $time > 6 MsgBox(1, "Bad", "Your internet speed is bad, look to get new service, it took: " & $time * .001 & "seconds") EndSwitch EndFunc ;==>dowork Link to comment Share on other sites More sharing options...
JustinReno Posted April 26, 2008 Share Posted April 26, 2008 A nicer, Cleaner version: Func dowork() $PublicIP = _GetIP() ToolTip("IP: " & $PublicIP) Sleep(1000) $time = Ping($PublicIP) Switch $time Case $time < 1 MsgBox(1, "ULTRA FAST", "Your internet speed is top notch, it took in seconds:" & $time * .001) Case $time < 2 And $time > 1 MsgBox(1, "GREAT", "Your internet speed is excellent, it took: " & $time * .001 & "seconds") Case $time < 3 And $time > 2 MsgBox(1, "Good", "Your internet speed is good, it took: " & $time * .001 & "seconds") Case $time < 4 And $time > 3 MsgBox(1, "Fair", "Your internet speed is fair, it took: " & $time * .001 & "seconds") Case $time < 5 And $time > 4 MsgBox(1, "Poor", "Your internet speed is poor, it took: " & $time * .001 & "seconds") Case $time > 6 MsgBox(1, "Bad", "Your internet speed is bad, look to get new service, it took: " & $time * .001 & "seconds") EndSwitch EndFunc ;==>doworkDoes this work for you? Link to comment Share on other sites More sharing options...
Swift Posted April 26, 2008 Share Posted April 26, 2008 Most certantly. Link to comment Share on other sites More sharing options...
JustinReno Posted April 26, 2008 Share Posted April 26, 2008 Oh, it doesn't for me, it doesn't even create a msg box. Link to comment Share on other sites More sharing options...
Swift Posted April 26, 2008 Share Posted April 26, 2008 hmm. Try this one. It's different. Func dowork() $PublicIP = _GetIP() $time = Ping($PublicIP) Switch $time Case 1 MsgBox(0, "ULTRA FAST", "Your internet speed is top notch") Case 2 MsgBox(0, "GREAT", "Your internet speed is excellent") Case 3 MsgBox(0, "Good", "Your internet speed is good") Case 4 MsgBox(0, "Fair", "Your internet speed is fair") Case 5 MsgBox(0, "Poor", "Your internet speed is poor") Case 6 MsgBox(0, "Bad", "Your internet speed is bad, look to get new service") Case Else MsgBox(0, "", "Your internet speed is unknown") EndSwitch EndFunc ;==>dowork Link to comment Share on other sites More sharing options...
JustinReno Posted April 26, 2008 Share Posted April 26, 2008 Cool, thanks, it worked: Results: "ULTRA FAST: Your internet speed is top notch!" Link to comment Share on other sites More sharing options...
Muchuchu Posted April 26, 2008 Author Share Posted April 26, 2008 I like that Swift, I'll be looking to use select cases more often because i'm starting to find out there is less room for error when using them. thanks Link to comment Share on other sites More sharing options...
therks Posted April 26, 2008 Share Posted April 26, 2008 A nicer, Cleaner version: Func dowork() $PublicIP = _GetIP() ToolTip("IP: " & $PublicIP) Sleep(1000) $time = Ping($PublicIP) Switch $time Case $time < 1 MsgBox(1, "ULTRA FAST", "Your internet speed is top notch, it took in seconds:" & $time * .001) Case $time < 2 And $time > 1 MsgBox(1, "GREAT", "Your internet speed is excellent, it took: " & $time * .001 & "seconds") Case $time < 3 And $time > 2 MsgBox(1, "Good", "Your internet speed is good, it took: " & $time * .001 & "seconds") Case $time < 4 And $time > 3 MsgBox(1, "Fair", "Your internet speed is fair, it took: " & $time * .001 & "seconds") Case $time < 5 And $time > 4 MsgBox(1, "Poor", "Your internet speed is poor, it took: " & $time * .001 & "seconds") Case $time > 6 MsgBox(1, "Bad", "Your internet speed is bad, look to get new service, it took: " & $time * .001 & "seconds") EndSwitch EndFunc ;==>dowork I know you already posted another version, but you do realize why your Switch statement here was flawed, right? I think you meant to use Select, instead of Switch. My AutoIt Stuff | My Github 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