Tag Archives: BIN2W()
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 |
FReadStr()
FREADSTR()
Reads a string from a file opened with low-level access
Syntax
FREADSTR(<nHandle>, <nBytes>) --> cString
Arguments
<nHandle> DOS file handle number.
<nBytes> Number of bytes to read.
Returns
<cString> an character expression
Description
This function returns a character string of <nBytes> bytes from a file whose DOS file handle is <nHandle>.
The value of the file handle <nHandle> is obtained from either the FOPEN() or FCREATE() functions.
The value of <nBytes> is the number of bytes to read from the file. The returned string will be the number of characters specified in <nBytes> or the number of bytes read before an end-of-file charac- ter (ASCII 26) is found.
NOTE This function is similar to the FREAD() function, except that it will not read binary characters that may he required as part of a header of a file construct. Characters Such as CHR(0) and CHR(26) may keep this function from performing its intended operation. In this event, the FREAD() function should he used in place of the FREADSTR() function.
Examples
#include "fileio.ch" IF ( nH := FOpen( "x.txt" ) ) != F_ERROR cStr := FReadStr( nH, 100 ) ? cStr FClose( nH ) ENDIF
Compliance
Clipper
Platforms
All (64K)
Files
Library is rtl
Seealso
FRead()
FREAD()
Reads bytes from a file opened by low-level access
Syntax
FREAD( <nHandle>, @<cBuffer>, <nBytes> ) --> nBytes
Arguments
<nHandle> Dos file handle
<cBuffer> Character expression passed by reference.
<nBytes> Number of bytes to read.
Returns
<nBytes> the number of bytes successfully read from the file. <nHandle>
Description
This function reads the characters from a file whose file handle is <nHandle> into a character memory variable expressed as <cBuffer>. The function returns the number of bytes successfully read into <cBuffer>.
The value of <nHandle> is obtained from either a call to the FOPEN() or the FCREATE() function.
The <cBuffer> expression is passed by reference and must be defined before this function is called. It also must be at least the same length as <nBytes>.
<nBytes> is the number of bytes to read, starting at the current file pointer position. If this function is successful in reading the characters from the file, the length of <cBuffer> or the number of bytes specified in <nBytes> will be the value returned. The current file pointer advances the number of bytes read with each successive read. The return value is the number of bytes successfully read from the file. If a 0 is returned, or if the number of bytes read matches neither the length of <cBuffer> nor the specified value in <nBytes> an end-of-file condition has been reached.
Examples
#include "fileio.ch" cBuffer := Space( 500 ) IF ( nH := FOpen( "x.txt" ) ) == F_ERROR FRead( nH, @cBuffer, 500 ) ? cbuffer ENDIF FClose( nH )
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()
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()
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()