User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

Bin2U()

 

Convert unsigned long encoded bytes into Harbour numeric

 

Syntax

 

Bin2U( <cBuffer> ) --> nNumber

 

Argument(s)

 

<cBuffer> is a character string that contain 32 bit encoded unsigned long integer (least significant byte first). The first four bytes are taken into account, the rest if any are ignored.

 

Returns

 

Bin2U() return numeric integer (or 0 if <cBuffer> is not a string).

 

Description

 

Bin2U() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. Bin2U() take four bytes of encoded 32 bit unsigned long integer and convert it into standard Harbour numeric value.

 

You might ask what is the need for such functions, well, first of all it allow you to read/write information from/to a binary file (like extracting information from DBF header), it is also a useful way to share information from source other than Harbour (C for instance).

 

Bin2U() is the opposite of U2Bin()

 

Example(s)

 

// Show number of records in DBF
#include "fileio.ch"
PROCEDURE Main()
   LOCAL nHandle, cBuffer := Space( 4 )
   nHandle := FOpen( "test.dbf" )
   IF nHandle != F_ERROR
      FSeek( nHandle, 4 )
      FRead( nHandle, @cBuffer, hb_BLen( cBuffer ) )
      ? "Number of records in file:", Bin2U( cBuffer )
      FClose( nHandle )
   ELSE
      ? "Can not open file"
   ENDIF
   RETURN

 

Status

 

Ready

 

Compliance

 

XPP

 

File(s)

 

Library is core

 

See also

Bin2I(), Bin2L(), Bin2W(), I2Bin(), L2Bin(), W2Bin(), Word(), U2Bin(), FRead()