Jump to content
Sign in to follow this  
supersonic

Trying to count @IPAddress[$i]

Recommended Posts

supersonic

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...???

Share this post


Link to post
Share on other sites
Xenobiologist

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

Share this post


Link to post
Share on other sites
supersonic

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 by supersonic

Share this post


Link to post
Share on other sites
James

@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 by JamesB

Share this post


Link to post
Share on other sites
Xenobiologist

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

Share this post


Link to post
Share on other sites
Xenobiologist

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

Share this post


Link to post
Share on other sites
James

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 :D

Share this post


Link to post
Share on other sites
Xenobiologist

#include <Array.au3> is not needed there :D

OMG, just tested something before, but right you are ... :D

+> "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

Share this post


Link to post
Share on other sites
supersonic

@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

Share this post


Link to post
Share on other sites
Xenobiologist

@Lazycat

That's my favorite...

Thank you!

Then you will only have ipadress4 in y

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

Share this post


Link to post
Share on other sites
supersonic

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 y

Mega

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  

×