scripting@wanadoo.nl




BinaryIP()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
20 March 2002 BinaryIP()
AuthorBryce Lindsay
Action Converts an IP address into a binary string.
SyntaxBinaryIP ("IP_Address") 
Parameters
  • IP_Address (Required / String) any IP Address such as "10.27.0.1" 
  • Remarksthis function will return the binary value of a given IP address. 
    Returnsa 32bit binary number as a string representing the given IP address. 
    DependenciesNone. 
    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 -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter