computergroove Posted December 16, 2014 Share Posted December 16, 2014 I have 5 devices on my network and I want to wait until I can ping all of them before I continue with my script. Here is my code snippet: Global $NumberOfDevices = 5 Global $IPAddress1 = "192.168.1.100" Global $IPAddress2 = "192.168.1.101" Global $IPAddress3 = "192.168.1.104" Global $IPAddress4 = "192.168.1.105" Global $IPAddress5 = "192.168.1.106" Global $IPArray[5] = [$IPAddress1, $IPAddress2, $IPAddress3, $IPAddress4, $IPAddress5] Global $PingRestartArray[5] = [0, 0, 0, 0, 0] Func PingDevices() Do For $i = 1 To $NumberOfDevices Local $Var = Ping($IPArray[$i], 1000) If $Var Then $PingRestartArray[$i] = 1 EndIf Next Until $PingRestartArray == [1, 1, 1, 1, 1];<-How should this look? $PingRestartArray = [0, 0, 0, 0, 0];<-How should this look? EndFunc I am getting an errorin the commented lines at the bottom. How do I compare an array at the until line? How do I reset all the values to 0 after Im done? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
UEZ Posted December 16, 2014 Share Posted December 16, 2014 (edited) Try this (untested): Global $NumberOfDevices = 5 Global $IPAddress1 = "192.168.1.100" Global $IPAddress2 = "192.168.1.101" Global $IPAddress3 = "192.168.1.104" Global $IPAddress4 = "192.168.1.105" Global $IPAddress5 = "192.168.1.106" Global $IPArray[5] = [$IPAddress1, $IPAddress2, $IPAddress3, $IPAddress4, $IPAddress5] Global $z Func PingDevices() Do $z = 0 For $i = 0 To $NumberOfDevices - 1 If Ping($IPArray[$i], 1000) Then $z += 1 Next Until $z = $NumberOfDevices EndFunc Br,UEZ Edited December 16, 2014 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
water Posted December 16, 2014 Share Posted December 16, 2014 (edited) Something like this (untested): Global $aIPAddress[} = ["192.168.1.100", "192.168.1.101", "192.168.1.104", "192.168.1.105". "192.168.1.106"] Func PingDevices() Local $iAdresses = UBound($aIPAddress) - 1 ; Number of addresses to ping Local $iPinged = 0 ; Number of successfully pinged adresses While 1 For $i = 0 To $iAdresses If $aIPAddress[$i] <> "" Then If Ping($aIPAddress[$i], 1000) <> 0 Then $aIPAddress[$i] = "" ; All successfully pinged adresses are removed from teh array $iPinged = $iPinged + 1 Else $iPinged = $iPinged + 1 EndIf EndIf Next If $iPinged = $iAdresses Then Return ; All addresses pinged WEnd EndFun Edited December 16, 2014 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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