Files
harbour-core/harbour/doc/en/binnum.txt
Viktor Szakats 7526351f80 2012-07-03 11:32 UTC+0200 Viktor Szakats (harbour syenar.net)
* doc/en/file.txt
    ! Spelling.
      by Alexey Myronenko
    ! some more

  * doc/en/array.txt
  * doc/en/binnum.txt
  * doc/en/browse.txt
    * formatted $EXAMPLES$
    * made $EXAMPLES$ unicode-ready
2012-07-03 09:34:31 +00:00

485 lines
15 KiB
Plaintext

/*
* $Id$
*/
/*
* The following parts are Copyright of the individual authors.
* www - http://harbour-project.org
*
* Copyright 2000 Chen Kedem <niki@actcom.co.il>
* Documentation for: BIN2W(), BIN2I(), BIN2L(), BIN2U(), I2BIN(), W2BIN(),
* L2BIN(), U2BIN()
*
* See COPYING for licensing terms.
*
*/
/* $DOC$
* $TEMPLATE$
* Function
* $NAME$
* BIN2W()
* $CATEGORY$
* API
* $SUBCATEGORY$
* Conversion
* $ONELINER$
* 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
* $STATUS$
* R
* $COMPLIANCE$
* C
* $FILES$
* Library is rtl
* $SEEALSO$
* BIN2I(),BIN2L(),BIN2U(),I2BIN(),L2BIN(),W2BIN(),WORD(),U2BIN(),FREAD()
* $END$
*/
/* $DOC$
* $TEMPLATE$
* Function
* $NAME$
* BIN2I()
* $CATEGORY$
* API
* $SUBCATEGORY$
* Conversion
* $ONELINER$
* 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
* $STATUS$
* R
* $COMPLIANCE$
* C
* $FILES$
* Library is rtl
* $SEEALSO$
* BIN2L(),BIN2U(),BIN2W(),I2BIN(),L2BIN(),W2BIN(),WORD(),U2BIN(),FREAD()
* $END$
*/
/* $DOC$
* $TEMPLATE$
* Function
* $NAME$
* BIN2L()
* $CATEGORY$
* API
* $SUBCATEGORY$
* Conversion
* $ONELINER$
* 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
* $STATUS$
* R
* $COMPLIANCE$
* C
* $FILES$
* Library is rtl
* $SEEALSO$
* BIN2I(),BIN2U(),BIN2W(),I2BIN(),L2BIN(),W2BIN(),WORD(),U2BIN(),FREAD()
* $END$
*/
/* $DOC$
* $TEMPLATE$
* Function
* $NAME$
* BIN2U()
* $CATEGORY$
* API
* $SUBCATEGORY$
* Conversion
* $ONELINER$
* 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
* $STATUS$
* R
* $COMPLIANCE$
* XPP
* $FILES$
* Library is rtl
* $SEEALSO$
* BIN2I(),BIN2L(),BIN2W(),I2BIN(),L2BIN(),W2BIN(),WORD(),U2BIN(),FREAD()
* $END$
*/
/* $DOC$
* $TEMPLATE$
* Function
* $NAME$
* I2BIN()
* $CATEGORY$
* API
* $SUBCATEGORY$
* Conversion
* $ONELINER$
* 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
* $STATUS$
* R
* $COMPLIANCE$
* C
* $FILES$
* Library is rtl
* $SEEALSO$
* BIN2I(),BIN2L(),BIN2U(),BIN2W(),L2BIN(),W2BIN(),WORD(),U2BIN(),FWRITE()
* $END$
*/
/* $DOC$
* $TEMPLATE$
* Function
* $NAME$
* W2BIN()
* $CATEGORY$
* API
* $SUBCATEGORY$
* Conversion
* $ONELINER$
* 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()
* $STATUS$
* R
* $COMPLIANCE$
* XPP
* $FILES$
* Library is rtl
* $SEEALSO$
* BIN2I(),BIN2L(),BIN2U(),BIN2W(),I2BIN(),L2BIN(),WORD(),U2BIN(),FWRITE()
* $END$
*/
/* $DOC$
* $TEMPLATE$
* Function
* $NAME$
* L2BIN()
* $CATEGORY$
* API
* $SUBCATEGORY$
* Conversion
* $ONELINER$
* 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()
* $STATUS$
* R
* $COMPLIANCE$
* C
* $FILES$
* Library is rtl
* $SEEALSO$
* BIN2I(),BIN2L(),BIN2U(),BIN2W(),I2BIN(),W2BIN(),WORD(),U2BIN(),FWRITE()
* $END$
*/
/* $DOC$
* $TEMPLATE$
* Function
* $NAME$
* U2BIN()
* $CATEGORY$
* API
* $SUBCATEGORY$
* Conversion
* $ONELINER$
* 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()
* $STATUS$
* R
* $COMPLIANCE$
* XPP
* $FILES$
* Library is rtl
* $SEEALSO$
* BIN2I(),BIN2L(),BIN2U(),BIN2W(),I2BIN(),L2BIN(),W2BIN(),WORD(),FWRITE()
* $END$
*/
/* $DOC$
* $TEMPLATE$
* Function
* $NAME$
* WORD()
* $CATEGORY$
* API
* $SUBCATEGORY$
* Conversion
* $ONELINER$
* Converts double to integer values.
* $SYNTAX$
* WORD( <nDouble> ) --> <nInteger>
* $ARGUMENTS$
* <nDouble> is a numeric double value.
* $RETURNS$
* WORD() return an integer in the range +-32767
* $DESCRIPTION$
* This function converts double values to integers to use
* within the CALL command
* $STATUS$
* R
* $COMPLIANCE$
* The CA-Cl*pper NG states that WORD() will only work when used in CALL
* commands parameter list, otherwise it will return NIL, in Harbour
* it will work anywhere.
* $FILES$
* Library is rtl
* $SEEALSO$
* CALL
* $END$
*/