xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Bin2W()

Converts an unsigned short binary integer (2 bytes) into a numeric value.

Syntax

Bin2W( <cInteger> ) --> nNumber

Arguments

<cInteger>
This is a character string whose first two bytes are converted to a 16 bit unsigned integer value of numeric data type.

Return

The function returns a numeric value in the range of 0 to +(2ˆ16) - 1.

Description

Bin2W() is a binary conversion function that converts a two byte binary number (Valtype()=="C") to a numeric value (Valtype()=="N"). The parameter <cInteger> is usually the return value of function W2Bin().

The range for the numeric return value is determined by an unsigned short integer.

Info

See also:Bin2I(), Bin2L(), Bin2U(), FRead(), I2Bin(), L2Bin(), U2Bin(), W2Bin(), Word()
Category: Binary functions , Conversion functions
Source:rtl\binnum.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example reads the header size from the file header
// of a DBF file and displays the converted numeric value.

   PROCEDURE Main()
      LOCAL nHandle
      LOCAL cInteger := Space( 2 )
      LOCAL cFile    := "Customer.dbf"

      nHandle := FOpen( cFile  )

      IF nHandle > 0
         FSeek( nHandle, 8 )
         FRead( nHandle, @cInteger, 2 )
         ? "Size of file header:", Bin2W( cInteger )
         FClose( nHandle )
      ELSE
         ? "Cannot open file:", cFile
      ENDIF

   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe