Convert signed short encoded bytes into Harbour numeric


      BIN2I( <cBuffer> ) --> nNumber


<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.


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


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()


      // Show DBF last update date
      #include ""
      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 )
            ? "Can not open file"




Library is rtl


BIN2L(), BIN2U(), BIN2W(), I2BIN(), L2BIN(), W2BIN(), WORD(), U2BIN(), FREAD()

3 responses to “Bin2I()

  1. Pingback: Harbour All Functions – B | Viva Clipper !

  2. Pingback: Harbour Conversion Functions | Viva Clipper !

  3. Pingback: Harbour RG Summary | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.