Page 1 of 1 1
Topic Options
#185532 - 2008-02-21 05:40 AM @IPADDRESSx "looping"....
jmuirh Offline
Fresh Scripter

Registered: 2007-09-22
Posts: 21
Hi,

Looking for a creative way to loop through the possible @IPADDRESSx system macros (@IPADDRESS0 through @IPADDRESS3):

A pseudo-code example would be something like:

 Code:
For $i = 0 to 3
   If InStr(@IPADDRESS<$i>,"192.168")
      Goto ExitLoop
   EndIf
Next
:ExitLoop


Possible? Any ideas?

Thanks.


Edited by jmuirh (2008-02-21 05:47 AM)

Top
#185533 - 2008-02-21 06:00 AM Re: @IPADDRESSx "looping".... [Re: jmuirh]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Execute() is the answer... Also, get rid of the goto.
$nul=setoption("NoMacrosinstrings","on")
$nul=setoption("NoVarsinstrings","on")
For $i = 0 to 3
   ? $i
   $ret=execute("$IP=@IPADDRESS" + $i)
   " " + $IP
   If InStr($IP,"192.168")
      ;do stuff 
   else
      ;do other stuff 
   EndIf
Next

Top
#185535 - 2008-02-21 07:04 AM Re: @IPADDRESSx "looping".... [Re: Allen]
jmuirh Offline
Fresh Scripter

Registered: 2007-09-22
Posts: 21
Cool! Thanks.

The goto was only my attempt to illustrate the need to dump out of the loop early when the desired IP is found.

Thanks again!

Top
#185548 - 2008-02-21 12:19 PM Re: @IPADDRESSx "looping".... [Re: jmuirh]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
; ===========================================================================================
;
;     Script Information
;    
;     Title:       LoopIPAddresses.kix
;     Author:      Wim Rotty
;     Description: Loop through all IP Addresses on a computer
;    
;
; ===========================================================================================
;Script Options

If Not @LOGONMODE
    Break On
Else
    Break Off
EndIf
Dim $RC
$RC = SetOption("Explicit", "On")
$RC = SetOption("NoMacrosInStrings", "On")
$RC = SetOption("NoVarsInStrings", "On")
If @SCRIPTEXE = "KIX32.EXE"
    $RC = SetOption("WrapAtEOL", "On")
EndIf

;Declare variables
Dim
 
$IPAddress, $i

;Initialize variables
$i = 0

;Code
$IPAddress = EnumIPInfo($i,0,1)
While Not @ERROR
    If Not $IPAddress = "0.0.0.0"
        ? $IPAddress
        ;Do stuff
    EndIf
    $i = $i + 1
   
$IPAddress = EnumIPInfo($i,0,1)
Loop

;Personal UDF Section

;UDF Section

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.05 seconds in which 0.021 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org