Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>bin2i()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
BIN2I()


Syntax:     BIN2I(<expC>)

Purpose:    To convert a character string formatted as a 16-bit signed
            integer to a Clipper numeric value.

Argument:   <expC> is a two-byte string in the form of a 16-bit
            signed integer number--least significant byte first.  If
            more than two characters are specified, the remaining are
            ignored.

Returns:    An integer numeric value.

Usage:      BIN2I() is used in combination with FREAD() to convert a
            two-byte character string formatted as a signed integer to a
            Clipper numeric.  This is most useful when you are reading
            foreign file types and want to read numeric data formatted
            in its native form.

Library:    EXTEND.LIB

Source:     EXAMPLEA.ASM


----------------------------------- Example --------------------------------

   This example opens a database file using low-level file functions and
   reads the date of last update (bytes 1-3).  The result is the same as
   with LUPDATE().

   handle = FOPEN("Sales.dbf")
   *
   * Point to byte 1 in the file.
   FSEEK(handle, 1, 0)
   *
   * Read date of last update.
   year  =  BIN2I(FREADSTR(handle, 1)) + CHR(0)
   month =  BIN2I(FREADSTR(handle, 1)) + CHR(0)
   day   =  BIN2I(FREADSTR(handle, 1)) + CHR(0)
   *
   ? LTRIM(STR(month)),;
       LTRIM(STR(day)), LTRIM(STR(year))
   FCLOSE(handle)


See Also: BIN2L() BIN2W() I2BIN() L2BIN() FREAD()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson