Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- GT_LIB v1.0 Reference Guide Release 1.0 - <b>turn a decimal number into hex</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 Turn a decimal number into hex
------------------------------------------------------------------------------

 Syntax

        GT_DtoH(<n> [,<nLength>]) --> <cHex>

 Arguments:

      <n>       is a decimal integer to convert

      <nLength> is the MINIMUM length string to return.  If the
                return string <cHex> is already longer than this, it
                is not truncated.  If shorter, it is padded with leading
                zero's.

 Returns:

      <cHex>    is a string representing a hexadecimal number.

 Description:

      This function allows you to convert from decimal to hex easily.  There
      are many uses for hex numbres in Clipper.

 Examples:

      ? GT_DtoH(255)         // 'FF'

      // This code builds attribute bytes...
      //
      // Attribute color table:
      // 0  = Black       8 = Grey
      // 1  = Blue        9 = Bright Blue
      // 2  = Green      10 = Bright Green
      // 3  = Cyan       11 = Bright Cyan
      // 4  = Red        12 = Bright Red
      // 5  = Magenta    13 = Bright Magenta
      // 6  = Brown      14 = Yellow
      // 7  = White      15 = Bright White

      cAttribute := SubStr(SaveScreen(0,0,0,0),2,1) // get att. byte
      cAttribute := GT_DtoH(Asc(cAttribute))        // make 2bytes

      /* now change background byte to bright/blinking white*/
      cAttribute := GT_DtoH(15)+SubStr(cAttribute,-1)

 Header File: gt_lib.ch

 Source: GTMATH05.PRG

 Author:  Philip Ide

See Also: GT_HTOD()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson