C5_BIN2W

 BIN2W()
 Convert a 16-bit unsigned integer to a numeric value
------------------------------------------------------------------------------
 Syntax

     BIN2W(<cUnsignedInt>) --> nNumber

 Arguments

     <cUnsignedInt> is a character string in the form of a 16-bit
     unsigned integer number--least significant byte first.  Only the first
     two characters are used by the function; all others are ignored.

 Returns

     BIN2W() returns an integer numeric value.

 Description

     BIN2W() is a low-level file function that is used with FREAD() to
     convert a two-byte character string formatted as an unsigned integer to
     a Clipper numeric data type.  This is most useful when you are
     reading from a binary file and want to read data in its native format.

 Examples

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

        #include "Fileio.ch"
        //
        nHandle := FOPEN("Sales.dbf", FO_READ)
        // Note:  The length of a record in Sales.dbf is 124
        //
        // Point to byte 10, the first record size byte
        FSEEK(nHandle, 10, FS_SET)
        //
        // Read record size
        cRecSize := SPACE(2)
        FREAD(nHandle, @cRecSize, 2)
        //
        ? LTRIM(STR(BIN2W(cRecSize)))            // Result: 124
        FCLOSE(nHandle)

 Files   Library is EXTEND.LIB, source file is SOURCE\SAMPLE\EXAMPLEA.ASM

See Also: BIN2I() BIN2L() FREAD() FREADSTR() I2BIN() L2BIN()

 

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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.