|
|
|
| 20 March 2002 | BinaryIP() |
| Author | Bryce Lindsay |
| Action | Converts an IP address into a binary string. |
| Syntax | BinaryIP ("IP_Address") |
| Parameters | |
| Remarks | this function will return the binary value of a given IP address. |
| Returns | a 32bit binary number as a string representing the given IP address. |
| Dependencies | None. |
| Examples | $binary = BinaryIP(@ipaddress0) |
| Source |
FUNCTION BinaryIP ($ip)
DIM $item, $bitsize, $octet
$bitsize = 128
$ip = Split($ip,".")
SELECT
CASE UBound($ip) <> 3
$binaryip = 0
EXIT(87)
CASE 1
FOR EACH $octet IN $ip
IF Val($octet) < 0 OR Val($octet) > 255
$binaryip = 0
EXIT(87)
ENDIF
WHILE ($bitsize > 0)
IF Val($octet) & $bitsize
$binary = $binary + "1"
ELSE
$binary = $binary + "0"
ENDIF
$bitsize = $bitsize / 2
LOOP
$binaryip = $binaryip + "$binary"
$bitsize = 128
$binary = ""
NEXT
ENDSELECT
EXIT(0)
ENDFUNCTION ; - BinaryIP -
|
|
|
|