supersonic Posted April 28, 2008 Posted April 28, 2008 Hi, I'm trying to evaluate from @IPAddress1 to @IPAddress4. One possible way is this: For $i = 1 to 4 Select Case $i = 1 $y = StringSplit(@IPAddress1, ".", 0) Case $i = 2 $y = StringSplit(@IPAddress2, ".", 0) Case $i = 3 $y = StringSplit(@IPAddress3, ".", 0) Case $i = 4 $y = StringSplit(@IPAddress4, ".", 0) EndSelect NextoÝ÷ Ù»Ëaz·mëmz¼Êܡا*&zØb bëaÌ(ºW[yø§y«¢+Ù½ÈÀÌØí¤ôÄѼÐ($ÀÌØíäôMÑÉ¥¹MÁ±¥Ð¡%AÉÍÍlÀÌØí¥t°ÅÕ½Ðì¸ÅÕ½Ðì°À¤)9á Any ideas...???
Xenobiologist Posted April 28, 2008 Posted April 28, 2008 Hi, ??? what should be the result? Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
supersonic Posted April 28, 2008 Author Posted April 28, 2008 (edited) I would like to compact the code. The result is an array ($y) containing a splitted IP-Address ($y[1] to $y[4]). Hi, ??? what should be the result? Mega Edited April 28, 2008 by supersonic
James Posted April 28, 2008 Posted April 28, 2008 (edited) @IPAddress does not return an array therefore not allowing anything such as @IPAddress[$i] to be used. Something like this? Func _RetIP() For $i = 1 To 4 Return $_ip = @IPAddress & $i Next EndFunc Untested. Edited April 28, 2008 by JamesB Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
rasim Posted April 28, 2008 Posted April 28, 2008 supersonicMayb this?Dim $aIP[5] = [4, @IPAddress1, @IPAddress2, @IPAddress3, @IPAddress4] For $i = 1 To $aIP[0] ConsoleWrite($aIP[$i] & @LF) $y = StringSplit($aIP[$i], ".", 0) Next
James Posted April 28, 2008 Posted April 28, 2008 supersonic Mayb this? Dim $aIP[5] = [4, @IPAddress1, @IPAddress2, @IPAddress3, @IPAddress4] For $i = 1 To $aIP[0] ConsoleWrite($aIP[$i] & @LF) $y = StringSplit($aIP[$i], ".", 0) NextMuch better way of doing it Rasim Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Xenobiologist Posted April 28, 2008 Posted April 28, 2008 Hi, should the result be 4 arrays in an array? Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Lazycat Posted April 28, 2008 Posted April 28, 2008 Maybe this is the rare job for Execute: For $i = 1 To 4 $y = StringSplit(Execute("@IPAddress" & $i), ".", 0) Next Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s])
Xenobiologist Posted April 28, 2008 Posted April 28, 2008 Or #include <Array.au3> #include <String.au3> Global $ip_A[4][4] ConsoleWrite('!' & @IPAddress1 & @CRLF) ConsoleWrite('!' & @IPAddress2 & @CRLF) ConsoleWrite('!' & @IPAddress3 & @CRLF) ConsoleWrite('!' & @IPAddress4 & @CRLF) _createIP_A() _printIP_A() Func _createIP_A() For $i = 0 To 3 $ip = _StringSplit(Execute("@IPAddress" & $i + 1), '.') For $y = 0 To 3 $ip_A[$y][$i] = $ip[$y] Next Next EndFunc ;==>_createIP_A Func _printIP_A() For $i = 0 To 3 For $y = 0 To 3 ConsoleWrite($ip_A[$y][$i] & @TAB) If $y = 3 Then ConsoleWrite(@CRLF) Next Next EndFunc ;==>printIP_A Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
James Posted April 28, 2008 Posted April 28, 2008 Or #include <Array.au3> #include <String.au3> Global $ip_A[4][4] ConsoleWrite('!' & @IPAddress1 & @CRLF) ConsoleWrite('!' & @IPAddress2 & @CRLF) ConsoleWrite('!' & @IPAddress3 & @CRLF) ConsoleWrite('!' & @IPAddress4 & @CRLF) _createIP_A() _printIP_A() Func _createIP_A() For $i = 0 To 3 $ip = _StringSplit(Execute("@IPAddress" & $i + 1), '.') For $y = 0 To 3 $ip_A[$y][$i] = $ip[$y] Next Next EndFunc ;==>_createIP_A Func _printIP_A() For $i = 0 To 3 For $y = 0 To 3 ConsoleWrite($ip_A[$y][$i] & @TAB) If $y = 3 Then ConsoleWrite(@CRLF) Next Next EndFunc ;==>printIP_A Mega#include <Array.au3> is not needed there Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Xenobiologist Posted April 28, 2008 Posted April 28, 2008 #include <Array.au3> is not needed there OMG, just tested something before, but right you are ... +> "Organize Includes" for AutoIt3 | Version 3.9 | © Th.Meger | 16.Apr.2008 !> ---------------------------------------------------------------------------------------------------- +> _StringSplit > String.au3 !> ---------------------------------------------------------------------------------------------------- >Exit code: 0 Time: 1.959 Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
supersonic Posted April 28, 2008 Author Posted April 28, 2008 @Lazycat That's my favorite... Thank you! Maybe this is the rare job for Execute: For $i = 1 To 4 $y = StringSplit(Execute("@IPAddress" & $i), ".", 0) Next
Xenobiologist Posted April 28, 2008 Posted April 28, 2008 @LazycatThat's my favorite...Thank you!Then you will only have ipadress4 in yMega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
supersonic Posted April 28, 2008 Author Posted April 28, 2008 After array "y" is created some more code lines follow, which were cut for posting...So I start with a value of 1, splitting the IP and run a UDF. Then I go on with value 2... And so on...Then you will only have ipadress4 in yMega
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