The EXECUTE line has been broken for readability. To run this UDF, you will have to unbreak the long line.
code:
; begin MOAN
;

;!
Function MOAN($a,$b,$c)
dim $, $z, $r, $1, $2, $3, $4

if $a+$b=$c
exit
endif

if not isdeclared($n)
global $n, $m[32], $s
; create 32bits of zeros and ones
$n=$m
$m=join($m,0)
$n=join($n,1)
$s='.'
endif

; create a function Z for validation and a modified binaryip function Y
; that is able to convert to/from binary ip addresses
$=execute("function z($a) dim $ $a=split($a,$s) $z=ubound($a) $=$a[0]
select case $z=0 and $='' $z='' case $z=3 $z=y($a)
case $z=0 and 0<$ and 31>$ $z=left($n,$)+left($m,32-$) case 1 $z=a endselect
endfunction
function y($i) dim $, $b, $c, $a if ubound($i)+1 $a='' for each $ in $i
if 0<$ or 255>$ $b=128 while $b if val($) & $b $a=$a+1
else $a=$a+0 endif $b=$b/2 loop endif next else redim $a[3] for $=0 to 3 $b=128
for $c=1 to 8 $a[$]=($b*substr($i,$*8+$c,1))+$a[$] $b=$b/2
next next $a=join($a,$s) endif $y=$a endfunction")

; validating the subnetmask
$c=z($c)
; validating the ip address
$a=z($a)
; validating the networkid
$b=z($b)

; exit if incorrect formatting
if $a=a or $b=a or $c=a
exit
endif

; z is being used in two placed
; to calculate networkid and to check whether ip is in network defined by networkid and subnetmask
$z=''
for $=1 to 32
$z=$z+(val(substr($a,$,1))&val(substr($c,$,1)))
next

select
case $a=''
; return array of ips based on networkid and subnetmask
$b=left($b,31)+1
$=instrrev($c,'1')
$=split(y(left($b,$)+substr($n,$+2)+0),$s)
$b=split(y($b),$s)
for $1=$b[0] to $[0]
for $2=$b[1] to $[1]
for $3=$b[2] to $[2]
for $4=$b[3] to $[3]
$r=ubound($a)+1
redim preserve $a[$r]
$a[$r]=''+$1+$s+$2+$s+$3+$s+$4
next
next
next
next
$r=join($a,',')
case $b=''
; return networkid based on ip and subnetmask
; ip AND subnetmask = networkid
if $z<>$a
$r=y($z)
endif
case $c=''
; return subnetmask based on ip and networkid
; ip AND networkid = subnetmask
$=instrrev($b,'1')
if left($a,$)=left($b,$)
for $r=$ to 30
$c=$c+'/'+$r+','
next
$c=left($c,len($c)-1)
else
$c=''
endif
$r=$c
case $a and $b and $c
; check whether ip is part of network defined by networkid and subnetmask
$r=$z=$b
case 1
; at least two empty inputs
endselect
$moan=$r
EndFunction
;!
;!

; end MOAN

And here's the results:
code:
KiXtart
KiXtart Version = 4.21
KiXGolf Script = kixgolf_moan.KIX

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

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: MOAN - Mother Of All Networks
Processing Start = 2003/05/30 15:00:27.791
Processing End = 2003/05/30 15:00:27.991
Duration = 0000/00/00 00:00:00.200
# Loops = 1
KiXGolf Result = passed (9 out of 9 correct)
KiXGolf Score = 1265

Thank you for participating in KiXtart Golf!



[ 30. May 2003, 21:39: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.