[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
BIN2I()

    Converts a character string formatted as a 16-bit signed integer to a
    Clipper numeric value.

Syntax

    BIN2I(<expC>)

Argument

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

Returns

    An integer numeric value.

Usage

    BIN2I() is used in combination with FREAD() or FREADSTR() to convert a
    two-byte character string 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.

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))               
    month = BIN2I(FREADSTR(handle, 1))               
    day   = BIN2I(FREADSTR(handle, 1))               
    *                                                
    ? LTRIM(STR(month)),;          && Result 9  1  87
        LTRIM(STR(day)), LTRIM(STR(year))            
    FCLOSE(handle)                                   

See Also: BIN2L BIN2W I2BIN L2BIN FOPEN FREAD FREADSTR
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson