Harbour All Functions – W

W2Bin

WaitPeriod

Week

Word

WordOne
WordOnly
WordRem
WordRepl
WordSwap

WordToChar

WOY

Advertisements

Conversion Functions

Harbour Conversion Functions

Bin2I Convert signed short encoded bytes into Harbour numeric
Bin2L Convert signed long encoded bytes into Harbour numeric
Bin2U Convert unsigned long encoded bytes into Harbour numeric
Bin2W Convert unsigned short encoded bytes into Harbour numeric
BitToC Converts position-dependent bits into characters
BinToDec Converts a Binary Value to Decimal
CToBit Converts a character string into a bit pattern
CToF Converts a special 8-byte string into a floating point number
CToN Converts a numeric string into a different base
DecToBin Converts a Decimal Value to Binary
DecToHexa Converts a Decimal Value to Hexa
DecToOctal Converts a Decimal Value to Octal
Fahrenheit Temperature conversion Celsius to Fahrenheit
FToC Converts a floating point number into a special 8-byte string
HexaToDec Converts a Hexa Value to Decimal
I2Bin Convert Harbour numeric into signed short encoded bytes
L2Bin Convert Harbour numeric into signed long encoded bytes
NToC Converts the numbers in a digit string into a different number base
OctalToDec Converts a Octal Value to Decimal
U2Bin Convert Harbour numeric into unsigned long encoded bytes
W2Bin Convert Harbour numeric into unsigned short encoded bytes
Word Converts double to integer values
XTOC Convert an expression to character type string

W2Bin()

W2Bin()

Convert Harbour numeric into unsigned short encoded bytes

Syntax

W2Bin( <nNumber> ) --> cBuffer

Arguments

<nNumber> is a numeric value to convert (decimal digits are ignored).

Returns

W2Bin() return two bytes character string that contain 16 bit encoded unsigned short integer (least significant byte first).

Description

     W2Bin() is one of the low level binary conversion functions, those functions convert between Harbour        numeric and a character representation of numeric value. W2Bin() take a numeric integer value and            convert it into two bytes of encoded 16 bit unsigned short integer.

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

          W2Bin() is the opposite of Bin2W()

Compliance

XPP

Files

Library is core

Seealso

Bin2I(), Bin2L(), Bin2U(), Bin2W(), I2Bin(), L2Bin(), Word(), U2Bin(), FWrite()

U2Bin()

U2Bin()

Convert Harbour numeric into unsigned long encoded bytes

Syntax


U2Bin( <nNumber> ) --> cBuffer

Arguments

<nNumber> is a numeric value to convert (decimal digits are ignored).

Returns

U2Bin() return four bytes character string that contain 32 bit encoded unsigned long integer (least significant byte first).

Description

U2Bin() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. U2Bin() take a numeric integer value and convert it into four bytes of encoded 32 bit unsigned long integer.

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

U2Bin() is the opposite of Bin2U()

Compliance

XPP

Files

Library is core

Seealso

Bin2I(), Bin2L(), Bin2U(), Bin2W(), I2Bin(), L2Bin(), W2Bin(), Word(), FWrite()

L2Bin()

L2BIN()

Convert Harbour numeric into signed long encoded bytes

Syntax

      L2BIN( <nNumber> ) --> cBuffer

Arguments

<nNumber> is a numeric value to convert (decimal digits are ignored).

Returns

L2BIN() return four bytes character string that contain 32 bit encoded signed long integer (least significant byte first).

Description

L2BIN() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. L2BIN() take a numeric integer value and convert it into four bytes of encoded 32 bit signed long integer.

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

L2BIN() is the opposite of BIN2L()

Compliance

Clipper

Files

Library is rtl

Seealso

BIN2I(), BIN2L(), BIN2U(), BIN2W(), I2BIN(), W2BIN(), WORD(), U2BIN(), FWRITE()

I2Bin()

I2BIN()

Convert Harbour numeric into signed short encoded bytes

Syntax

      I2BIN( <nNumber> ) --> cBuffer

Arguments

<nNumber> is a numeric value to convert (decimal digits are ignored).

Returns

I2BIN() return two bytes character string that contain 16 bit encoded signed short integer (least significant byte first).

Description

I2BIN() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. I2BIN() take a numeric integer value and convert it into two bytes of encoded 16 bit signed short integer.

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

I2BIN() is the opposite of BIN2I()

Examples

      // Update DBF "last update" date
      #include "fileio.ch"
      PROCEDURE Main()
         LOCAL nHandle, cYear, cMonth, cDay
         USE test
         ? "Original update date is:", LUpdate()
         CLOSE
         nHandle := FOpen( "test.dbf", FO_READWRITE )
         IF nHandle != F_ERROR
            FSeek( nHandle, 1 )
            cYear  := I2Bin( 68 )
            cMonth := I2Bin(  8 )
            cDay   := I2Bin(  1 )
            FWrite( nHandle, cYear , 1 )   // write only the first byte
            FWrite( nHandle, cMonth, 1 )
            FWrite( nHandle, cDay  , 1 )
            FClose( nHandle )
            USE test
            ? "New update date is:", lupdate()
            CLOSE
         ELSE
            ? "Can not open file"
         ENDIF
         RETURN

Compliance

Clipper

Files

Library is rtl

Seealso

BIN2I(), BIN2L(), BIN2U(), BIN2W(), L2BIN(), W2BIN(), WORD(), U2BIN(), FWRITE()

Bin2W()

 

BIN2W()

Convert unsigned short encoded bytes into Harbour numeric

Syntax

      BIN2W( <cBuffer> ) --> nNumber

Arguments

<cBuffer> is a character string that contain 16 bit encoded unsigned short integer (least significant byte first). The first two bytes are taken into account, the rest if any are ignored.

Returns

BIN2W() return numeric integer (or 0 if <cBuffer> is not a string).

Description

BIN2W() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. BIN2W() take two bytes of encoded 16 bit unsigned 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).

BIN2W() is the opposite of W2BIN()

Examples

      // Show header length of a DBF
      #include "fileio.ch"
      PROCEDURE Main()
         LOCAL nHandle, cBuffer := Space( 2 )
         nHandle := FOpen( "test.dbf" )
         IF nHandle != F_ERROR
            FSeek( nHandle, 8 )
            FRead( nHandle, @cBuffer, hb_BLen( cBuffer ) )
            ? "Length of DBF header in bytes:", Bin2W( cBuffer )
            FClose( nHandle )
         ELSE
            ? "Can not open file"
         ENDIF
         RETURN

Compliance

Clipper

Files

Library is rtl

Seealso

BIN2I(), BIN2L(), BIN2U(), I2BIN(), L2BIN(), W2BIN(), WORD(), U2BIN(), FREAD()