User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

Bin2I()

 

Convert signed short encoded bytes into Harbour numeric

 

Syntax

 

Bin2I( <cBuffer> ) --> nNumber

 

Argument(s)

 

<cBuffer> is a character string that contain 16 bit encoded signed short integer (least significant byte first). The first two bytes are taken into account, the rest if any are ignored.

 

Returns

 

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

 

Description

 

Bin2I() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. Bin2I() take two bytes of encoded 16 bit signed short 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).

 

Bin2I() is the opposite of I2Bin()

 

Example(s)

 

// Show DBF last update date
#include "fileio.ch"
PROCEDURE Main()
   LOCAL nHandle, cYear, cMonth, cDay
   nHandle := FOpen( "test.dbf" )
   IF nHandle != F_ERROR
      FSeek( nHandle, 1 )
      cYear := cMonth := cDay := " "
      FRead( nHandle, @cYear , hb_BLen( cYear ) )
      FRead( nHandle, @cMonth, hb_BLen( cMonth ) )
      FRead( nHandle, @cDay  , hb_BLen( cDay ) )
      ? "Last update:", Bin2I( cYear ), Bin2I( cMonth ), Bin2I( cDay )
      FClose( nHandle )
   ELSE
      ? "Can not open file"
   ENDIF
   RETURN

 

Status

 

Ready

 

Compliance

 

This is CA-Cl*pper v5.2 compliant

 

File(s)

 

Library is core

 

See also

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