Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : NFSRC21.ZIP
Filename : HEX2DEC.PRG

 
Output of file : HEX2DEC.PRG contained in archive : NFSRC21.ZIP
/*
* File......: HEX2DEC.PRG
* Author....: Robert A. DiFalco
* Date......: $Date: 17 Aug 1991 15:32:56 $
* Revision..: $Revision: 1.3 $
* Log file..: $Logfile: E:/nanfor/src/hex2dec.prv $
*
* This is an original work by Robert DiFalco and is placed in the
* public domain.
*
* Modification history:
* ---------------------
*
* $Log: E:/nanfor/src/hex2dec.prv $
*
* Rev 1.3 17 Aug 1991 15:32:56 GLENN
* Don Caton fixed some spelling errors in the doc
*
* Rev 1.2 15 Aug 1991 23:03:42 GLENN
* Forest Belt proofread/edited/cleaned up doc
*
* Rev 1.1 14 Jun 1991 19:51:58 GLENN
* Minor edit to file header
*
* Rev 1.0 01 Apr 1991 01:01:28 GLENN
* Nanforum Toolkit
*
*/


/*
* $DOC$
* $FUNCNAME$
* FT_HEX2DEC()
* $CATEGORY$
* Conversion
* $ONELINER$
* Convert a hex number to decimal
* $SYNTAX$
* FT_HEX2DEC( ) -> nDecNum
* $ARGUMENTS$
* is a character string representing a hex number.
* $RETURNS$
* A decimal number.
* $DESCRIPTION$
* Converts a hexadecimal number to a BASE 10 decimal number.
* Useful for using FT_INT86().
* $EXAMPLES$
* FT_INT86( HEX2DEC( "21" ), aRegs )
*
* Converts 21h, the Dos Interrupt, to its decimal equivalent,
* 33, for use by FT_INT86().
* $END$
*/

#define HEXTABLE "0123456789ABCDEF"

#ifdef FT_TEST
FUNCTION MAIN( cHexNum )
QOut( FT_HEX2DEC( cHexNum ) )
return ( nil )
#endif

FUNCTION FT_HEX2DEC( cHexNum )
local n, nDec := 0, nHexPower := 1

for n := len( cHexNum ) to 1 step -1
nDec += ( at( subs( upper(cHexNum), n, 1 ), HEXTABLE ) - 1 ) * nHexPower
nHexPower *= 16
next

RETURN nDec


  3 Responses to “Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : NFSRC21.ZIP
Filename : HEX2DEC.PRG

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/