Sign in to follow this  
Followers 0
autoitxp

Ping and exit to second loop

11 posts in this topic

Hi

i have little problem using ping function here is script im working on it if $var=0 not works for me donno y and tell if i disable lan then how to successfully exitloop in function _monitor

While 1
sleep(100)
$var = Ping('192.168.0.42' ,250)
If $var = 1 Then call('_monitor')
WEnd
    
    
Func _monitor()
While 1
sleep(10)
If $var = 0 Then ExitLoop
Msgbox(0,"Status","ip online")
WEnd
EndFunc

Share this post


Link to post
Share on other sites



While 1
sleep(100)
$var = Ping('192.168.0.42' ,250)
If $var = 1 Then call('_monitor')
WEnd    
    
Func _monitor()
While 1
sleep(10)
If $var = 0 Then ExitLoop
Msgbox(0,"Status","ip online")
WEnd
EndFunc
At the top of your script add

Global $var

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi

i have little problem using ping function here is script im working on it if $var=0 not works for me donno y and tell if i disable lan then how to successfully exitloop in function _monitor

While 1
sleep(100)
$var = Ping('192.168.0.42' ,250)
If $var = 1 Then call('_monitor')
WEnd
    
    
Func _monitor()
While 1
sleep(10)
If $var = 0 Then ExitLoop
Msgbox(0,"Status","ip online")
WEnd
EndFunc
You are NOT updating $var in the _Monitor func. so you created an endless loop

At the top of your script add

Global $var

Is the same as the original script.. When the Variable is Set in the main of the script it will have a Global scope. Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

yup but still im not successfully exit to second loop even i disable my lan how to successfully exitloop if $var = 0 then exitloop

Edited by autoitxp

Share this post


Link to post
Share on other sites

i have little problem using ping function here is script im working on it if $var=0 not works for me donno y and tell if i disable lan then how to successfully exitloop in function _monitor

While 1
sleep(100)
$var = Ping('192.168.0.42' ,250)
If $var = 1 Then call('_monitor')
WEnd
    
    
Func _monitor()
While 1
sleep(10)
If $var = 0 Then ExitLoop
Msgbox(0,"Status","ip online")
WEnd
EndFunc

Yeah what JdeB said.

; I'm here because $var = 1

Func _monitor()

While 1

sleep(10)

; $var never = 0

If $var = 0 Then ExitLoop

Msgbox(0,"Status","ip online")

WEnd

EndFunc

Share this post


Link to post
Share on other sites

this code works but take to much bandwidth while checking ping any better soultion will be appreciated

While 1
sleep(100)
$var = Ping('192.168.0.42' ,250)
If $var = 1 Then call('_monitor')
WEnd
    
    
Func _monitor()
While 1
sleep(10)
$var = Ping('192.168.0.42' ,250)
If @error Then ExitLoop
Msgbox(0,"Status","ip online")
WEnd
EndFunc

Share this post


Link to post
Share on other sites

this code works but take to much bandwidth while checking ping any better soultion will be appreciated

Maybe you can first tell us what you want to do here... I am lost why you have the Unsuccessful Ping call the _Monitor func.....


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Is the intent to sit in _monitor until you have a good connection or just periodically check to see if a connection is available?

Share this post


Link to post
Share on other sites

I too am not sure what you want to do with Ping().

Share this post


Link to post
Share on other sites

im trying to detect internet connection if internet is detected it show ip is online otherwise Continue first loop if u guyz have better way to detect internet connection then share with me

Share this post


Link to post
Share on other sites

im trying to detect internet connection if internet is detected it show ip is online otherwise Continue first loop if u guyz have better way to detect internet connection then share with me

While 1
    If Not _NetCheck()Then
        MsgBox(0,"Status","We have a network connection",5)
        ExitLoop
    EndIf
    Sleep(10000);wait 10 seconds and try again
WEnd


Func _NetCheck()
    Ping('192.168.0.42' ,250)   ; 192.168.0.1
    return @error
EndFunc

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