autoitxp Posted February 4, 2006 Share Posted February 4, 2006 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 Link to comment Share on other sites More sharing options...
Laine Posted February 4, 2006 Share Posted February 4, 2006 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 Link to comment Share on other sites More sharing options...
Developers Jos Posted February 4, 2006 Developers Share Posted February 4, 2006 (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 EndFuncYou 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 February 4, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
autoitxp Posted February 4, 2006 Author Share Posted February 4, 2006 (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 February 4, 2006 by autoitxp Link to comment Share on other sites More sharing options...
Laine Posted February 4, 2006 Share Posted February 4, 2006 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 Link to comment Share on other sites More sharing options...
autoitxp Posted February 4, 2006 Author Share Posted February 4, 2006 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 Link to comment Share on other sites More sharing options...
Developers Jos Posted February 4, 2006 Developers Share Posted February 4, 2006 this code works but take to much bandwidth while checking ping any better soultion will be appreciatedMaybe you can first tell us what you want to do here... I am lost why you have the Unsuccessful Ping call the _Monitor func..... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Laine Posted February 4, 2006 Share Posted February 4, 2006 Is the intent to sit in _monitor until you have a good connection or just periodically check to see if a connection is available? Link to comment Share on other sites More sharing options...
PerryRaptor Posted February 4, 2006 Share Posted February 4, 2006 I too am not sure what you want to do with Ping(). Link to comment Share on other sites More sharing options...
autoitxp Posted February 4, 2006 Author Share Posted February 4, 2006 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 Link to comment Share on other sites More sharing options...
Laine Posted February 4, 2006 Share Posted February 4, 2006 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 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