; This loads an array of W.X.Y.Z/mask network ranges
$aNetworks = EnumIni('\\server\share\subnets.ini', 'SUBNET_LOOKUP') ; load subnet table from common location
; Get my IP address in normalized (no spaces) format
$MyIP = Join(Split($IPADDRESS0, ' '), '') ; remove spaces
; Pass IP and network table to UDF, returning an array of 0/1 values.
; If the table is defined in most to least specific order, the first
; value that is set represents the network subnet where the host resides
$aNetwork = IsInSubnet($MyIP, $aNetworks) ; get network ID (array element)
; find the first "1" in the array returned (may required additional args)
$Net = AScan($aNetwork, 1) ; get first network that host is a member of
; Using the element returned above, get the value to read from the INI file
$Network = $aNetworks($Net) ; return the network/mask for lookup
; Read the server name from the central INI file
$Server = ReadProfileString('\\server\share\subnets.ini', 'SUBNET_LOOKUP', $Network) ; lookup the server name for this network