Lonk, take that! Pat, you too! [Big Grin] Just a cheap couple strokes, but it is enough for now. [Razz]
code:
KiXtart Golf Score
Tournament = KiXtart Golf: MOAN - Mother Of All Networks
Processing Start = 2003/06/01 10:08:43.400
Processing End = 2003/06/01 10:08:43.500
Duration = 0000/00/00 00:00:00.099
# Loops = 1
KiXGolf Result = passed (10 out of 10 correct)
KiXGolf Score = 715

code:
; begin MOAN
;
;!
Function moan($a,$b,$c)
Dim $,$d,$e,$f,$g,$h,$m[3]
$d="."

;Build Subnet Mask
$f=0,128,192,224,240,248,252,254
for $e=8 to 31
$=$e
$h=1
for $g=0 to 3
$m[$g]=iif($/8,255,$f[$ mod 8])
$=iif($>8,$-8,0)
if $a & $b
$h=$h & 0+split($b,$d)[$g]=(0+split($a,$d)[$g] & $m[$g])
else
$h=0
endif
next
if $h
$c=$c+" /"+$e
endif
if $e=$c
$c=join($m,$d)
endif
next
;End build mask array
if instr($c,$d)
;build array of input values by splitting a string. Then convert to integers
; Mask = $[0..3] NetID = $[4..7] IPaddr = $[8..11]
$="..."
$=split($c+$d+IIF($b,$b,$)+$d+IIF($a,$a,$),$d)
if 0=$a
;Output: Network ID or empty string if no match
;Output: Array of all potential IP addresses or empty string if no match
for $b=0+$[4] to 255 + $[4] - $[0]
for $c=0+$[5] to 255 + $[5] - $[1]
for $e=0+$[6] to 255 + $[6] - $[2]
for $f=1+$[7] to 254 + $[7] - $[3]
$a = $a+" "+$b+$d+$c+$d+$e+$d+$f
next
next
next
next
$c=$a
else
;Calculate NetworkID using $ array
$c=""
for $e=0 to 3
$c=$c+$d+(0+$[$e] & 0+$[$e+8])
next
if $d+join(split($a),"")=$c
$c=""
endif

;Output: 1 if the IP is a member of a nework defined by network ID and subnet mask, otherwise 0
;Input NetworkID = Calculated NetworkID
if $b
$c=IIF($d+join(split($b),"")=$c,1,0)
endif
endif
endif
$moan=iif(len($c)>1,split(substr($c,2)),$c)
EndFunction
;!
;!
; end MOAN



[ 01. June 2003, 16:04: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/