BIN2U()

Convert unsigned long encoded bytes into Harbour numeric

Syntax

BIN2U( <cBuffer> ) --> nNumber

Arguments

<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()
Examples
      // Show number of records in DBF
      FUNCTION main()
      LOCAL nHandle, cBuffer := space( 4 )
      nHandle := fopen( "test.dbf" )
      IF nHandle > 0
         fseek( nHandle, 4 )
         fread( nHandle, @cBuffer, 4 )
         ? "Number of records in file:", BIN2U( cBuffer )
         fclose( nHandle )
      ELSE
         ? "Can not open file"
      ENDIF
      RETURN NIL
Status

Ready

Compliance

BIN2U() is an XBase++ compatibility function and does not exist as a standard CA-Clipper 5.x function. This function is only visible if source/rtl/binnum.c was compiled with the HB_COMPAT_XPP flag.

Files

Library is rtl

See Also