computergroove Posted August 21, 2014 Posted August 21, 2014 Sometimes I have 2 IP addresses, Sometimes 3, Sometimes 4 etc. The IP Addresses are not sequential. I want to make a for loop for each IP Address. Right now I just do it the long way without an array. Func StartVNC() Local $Number = 3;Number of IP Addresses Local $IP1 = "192.168.1.104", $IP2 = "192.168.1.108", $IP3 = "192.168.1.138" For 1 To $Number ;Do Something with the IP Address Next If I were to add the ip addresses in an array then I can better see how this would make logical sense. Any help? 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
ricky Posted August 21, 2014 Posted August 21, 2014 Hello, and like that : Func StartVNC() Local $a_IP[4] = [3,"192.168.1.104","192.168.1.108","192.168.1.138"] For $i = 1 To Ubound($a_IP) -1 ;Do Something with the IP Address Next And if you need, you increase the size of the array.
Danyfirex Posted August 21, 2014 Posted August 21, 2014 could do something like this: Local $aArray[3]=["192.168.1.104","192.168.1.108","192.168.1.138"] For $sIP in $aArray ConsoleWrite($sIP & @CRLF) Next Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Moderators JLogan3o13 Posted August 21, 2014 Moderators Posted August 21, 2014 (edited) I believe the question that should be asked is when do you know how many IP addresses you will have? Do you know at the beginning of the script (which would allow you to use something like ricky03 pointed out). Or is it going to be given to you through the script as feedback of some sort. Something like this? Ex: I know one IP, but there may be more... #include <Array.au3> #include <MsgboxConstants.au3> Local $ipArray[1] = ["192.168.1.104"] While 1 $ask = InputBox("Please enter an IP address", "") _ArrayAdd($ipArray, $ask) $confirm = MsgBox($MB_YESNO, "IP Array Example", "Would you like to add another?") If $confirm = $IDNO Then ExitLoop WEnd _ArrayDisplay($ipArray) Edited August 21, 2014 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
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