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

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

Syntax

    BIN2W(<expC>)

Argument

    <expC> is a two-byte string in the form of a 16-bit unsigned or long
    integer number.

Returns

    An integer numeric value.

Usage

    BIN2W() 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 number of bytes per record (bytes 10-11).  The result is the
    same as with RECSIZE():

    handle = FOPEN("Sales.dbf")                      
    *                                                
    * Point to byte 10 in the file                   
    FSEEK(handle, 10, 0)                             
    *                                                
    * Read record size                               
    rec_size = SPACE(2)                              
    FREAD(handle, @rec_size, 2)                      
    *                                                
    ? LTRIM(STR(BIN2W(rec_size)))    && Result 124   
    FCLOSE(handle)                                   

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