Tag Archives: L2BIN()
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 |
FWrite()
FWRITE()
Writes characters to a file opened with low-level access
Syntax
FWRITE( <nHandle>, <cBuffer>, [<nBytes>] ) --> nBytesWritten
Arguments
<nHandle> DOS file handle number.
<cBuffer> Character expression to be written.
<nBytes> The number of bytes to write.
Returns
<nBytesWritten> the number of bytes successfully written.
Description
This function writes the contents of <cBuffer> to the file designated by its file handle <nHandle>. If used, <nBytes> is the number of bytes in <cBuffer> to write.
The returned value is the number of bytes successfully written to the DOS file. If the returned value is 0, an error has occurred (unless this is intended). A successful write occurs when the number returned by FWRITE() is equal to either LEN( <cBuffer>) or <nBytes>.
The value of <cBuffer> is the string or variable to be written to the open DOS file <nHandle>.
The value of <nBytes> is the number of bytes to write out to the file. The disk write begins with the current file position in <nHandle>. If this variable is not used, the entire contents of <cBuffer> is written to the file. To truncate a file, a call of FWRITE( nHandle, “”, 0 ) is needed.
Examples
nHandle := FCreate( "x.txt" ) FOR X := 1 TO 10 FWrite( nHandle, Str( x ) ) NEXT FClose( nHandle )
Compliance
Clipper
Platforms
All (64K)
Files
Library is rtl
Seealso
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()
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()
Bin2U()
BIN2U()
Convert unsigned long encoded bytes into Harbour numeric
Syntax
BIN2U( <cBuffer> ) --> nNumber
Arguments
<cBuffer> is a character string that contain 32 bit encoded unsigned long integer (least significant byte first). The first four bytes are taken into account, the rest if any are ignored.
Returns
BIN2U() return numeric integer (or 0 if <cBuffer> is not a string).
Description
BIN2U() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. BIN2U() take four bytes of encoded 32 bit unsigned long 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).
BIN2U() is the opposite of U2BIN()
Examples
// Show number of records in DBF #include "fileio.ch" PROCEDURE Main() LOCAL nHandle, cBuffer := Space( 4 ) nHandle := FOpen( "test.dbf" ) IF nHandle != F_ERROR FSeek( nHandle, 4 ) FRead( nHandle, @cBuffer, hb_BLen( cBuffer ) ) ? "Number of records in file:", Bin2U( cBuffer ) FClose( nHandle ) ELSE ? "Can not open file" ENDIF RETURN
Compliance
XPP
Files
Library is rtl
Seealso
BIN2I(), BIN2L(), BIN2W(), I2BIN(), L2BIN(), W2BIN(), WORD(), U2BIN(), FREAD()
Bin2L()
BIN2L()
Convert signed long encoded bytes into Harbour numeric
Syntax
BIN2L( <cBuffer> ) --> nNumber
Arguments
<cBuffer> is a character string that contain 32 bit encoded signed long integer (least significant byte first). The first four bytes are taken into account, the rest if any are ignored.
Returns
BIN2L() return numeric integer (or 0 if <cBuffer> is not a string).
Description
BIN2L() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. BIN2L() take four bytes of encoded 32 bit signed long 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).
BIN2L() is the opposite of L2BIN()
Examples
// Show number of records in DBF #include "fileio.ch" PROCEDURE Main() LOCAL nHandle, cBuffer := Space( 4 ) nHandle := FOpen( "test.dbf" ) IF nHandle != F_ERROR FSeek( nHandle, 4 ) FRead( nHandle, @cBuffer, hb_BLen( cBuffer ) ) ? "Number of records in file:", Bin2L( cBuffer ) FClose( nHandle ) ELSE ? "Can not open file" ENDIF RETURN
Compliance
Clipper
Files
Library is rtl
Seealso
BIN2I(), BIN2U(), BIN2W(), I2BIN(), L2BIN(), W2BIN(), WORD(), U2BIN(), FREAD()
Bin2I()
BIN2I()
Convert signed short encoded bytes into Harbour numeric
Syntax
BIN2I( <cBuffer> ) --> nNumber
Arguments
<cBuffer> is a character string that contain 16 bit encoded signed short integer (least significant byte first). The first two bytes are taken into account, the rest if any are ignored.
Returns
BIN2I() return numeric integer (or 0 if <cBuffer> is not a string).
Description
BIN2I() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. BIN2I() take two bytes of encoded 16 bit signed 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).
BIN2I() is the opposite of I2BIN()
Examples
// Show DBF last update date #include "fileio.ch" PROCEDURE Main() LOCAL nHandle, cYear, cMonth, cDay nHandle := FOpen( "test.dbf" ) IF nHandle != F_ERROR FSeek( nHandle, 1 ) cYear := cMonth := cDay := " " FRead( nHandle, @cYear , hb_BLen( cYear ) ) FRead( nHandle, @cMonth, hb_BLen( cMonth ) ) FRead( nHandle, @cDay , hb_BLen( cDay ) ) ? "Last update:", Bin2I( cYear ), Bin2I( cMonth ), Bin2I( cDay ) FClose( nHandle ) ELSE ? "Can not open file" ENDIF RETURN
Compliance
Clipper
Files
Library is rtl
Seealso
BIN2L(), BIN2U(), BIN2W(), I2BIN(), L2BIN(), W2BIN(), WORD(), U2BIN(), FREAD()