# BIN2I()

Convert signed short encoded bytes into Harbour numeric

Syntax

  BIN2I( <cBuffer> ) --> nNumber

Arguments

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

Examples

          // Show DBF last update date
          FUNCTION main()
          LOCAL nHandle, cYear, cMonth, cDay
          nHandle := fopen( "test.dbf" )
          IF nHandle > 0
             fseek( nHandle, 1 )
             cYear := cMonth := cDay := " "
             fread( nHandle, @cYear , 1 )
             fread( nHandle, @cMonth, 1 )
             fread( nHandle, @cDay  , 1 )
             ? "Last update:", BIN2I( cYear ), BIN2I( cMonth ), BIN2I( cDay )
             fclose( nHandle )
          ELSE
             ? "Can not open file"
          ENDIF
          RETURN NIL

Status

  Ready

Compliance

  BIN2I() works exactly like CA-Clipper's BIN2I()

Files

  Library is rtl

See Also

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