Sign in to follow this  
Followers 0
Muchuchu

Variable Trouble

12 posts in this topic

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.

func 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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

func 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 :D

Edited 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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Isnt ping in milliseconds?

Edited by Zed

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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
Does this work for you?

Share this post


Link to post
Share on other sites

Most certantly.

Share this post


Link to post
Share on other sites

Oh, it doesn't for me, it doesn't even create a msg box.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Cool, thanks, it worked: Results:

"ULTRA FAST: Your internet speed is top notch!"

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

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