code:
KiXtart
KiXtart Version = 4.21
KiXGolf Script = kixgolf_moan.kix

Computer
OS = Windows 2000 Professional
CPU = Intel Pentium III
Speed = 848 MHz
Memory = 512 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: MOAN - Mother Of All Networks
Processing Start = 2003/06/01 00:37:40.715
Processing End = 2003/06/01 00:37:40.815
Duration = 0000/00/00 00:00:00.099
# Loops = 1
KiXGolf Result = passed (10 out of 10 correct)
KiXGolf Score = 746

Thank you for participating in KiXtart Golf!

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

;Build Subnet Mask
$f=0,128,192,224,240,248,252,254,255
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
$=split(substr($c,2))

;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)
for $g=0 to 11
$[$g]=0+$[$g]
next
if $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=$[4] to $[4] + 255 - $[0]
for $c=$[5] to $[5] + 255 - $[1]
for $e=$[6] to $[6] + 255 - $[2]
for $f=$[7]+1 to $[7] + 254 - $[3]
$a = $a+" "+$b+$d+$c+$d+$e+$d+$f
next
next
next
next
$=split(substr($a,2))
else
;Calculate NetworkID using $ array
$e=""
for $c=0 to 3
$e=$e+$d+($[$c] & $[$c+8])
next
$=substr($e,2)
if join(split($a),"")=$
$=""
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
$=IIF(join(split($b),"")=$,1,0)
endif
endif
endif
$moan=$
EndFunction
;!
;!
; end MOAN

_________________________
Home page: http://www.kixhelp.com/hb/