home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / x2char.prg < prev    next >
Text File  |  1993-10-14  |  2KB  |  87 lines

  1. /*
  2.  * File......: X2CHAR.PRG
  3.  * Author....: Martin Colloby
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Martin Colloby
  7.  * Date......: 18/4/93
  8.  * Revision..: 1.0
  9.  *
  10.  * This is an original work by Martin Colloby and is placed in the public
  11.  * domain.
  12.  *
  13.  * Modification history:
  14.  * ---------------------
  15.  *
  16.  * $Log$
  17.  *
  18.  */
  19.  
  20.  
  21. /*  $DOC$
  22.  *  $FUNCNAME$
  23.  *      GT_X2CHAR()
  24.  *  $CATEGORY$
  25.  *      String
  26.  *  $ONELINER$
  27.  *      Convert a value of any type into a string
  28.  *  $SYNTAX$
  29.  *      GT_X2Char( xExp )
  30.  *  $ARGUMENTS$
  31.  *      xExp - Expression to convert
  32.  *  $RETURNS$
  33.  *      A string of xExp
  34.  *  $DESCRIPTION$
  35.  *      Finds the type of xExp and converts it to a string
  36.  *  $EXAMPLES$
  37.  *
  38.  *  $SEEALSO$
  39.  *
  40.  *  $INCLUDE$
  41.  *
  42.  *  $END$
  43.  */
  44.  
  45. *
  46. FUNCTION GT_X2Char( xValue , nWidth )
  47.  
  48. /*****************************************************************************
  49.  Purpose - Convert any type into a justified char of the given width
  50.  Returns - Char value
  51.  Author  - Log
  52.  Created - 19/01/93
  53. ******************************************************************************
  54.  Parameters - xValue - Value to convert to char
  55.               nWidth - Width to make char
  56.  Privates   - None
  57.  Locals     - None
  58.  Externals  - None
  59. *****************************************************************************/
  60.  
  61. DO CASE
  62.     CASE VALTYPE( xValue ) == "N"
  63.         xValue := PADL( STR( xValue ) , nWidth )
  64.  
  65.     CASE VALTYPE( xValue ) == "D"
  66.         xValue := PADR( DTOC( xValue ) , nWidth )
  67.  
  68.     CASE VALTYPE( xValue ) == "C"
  69.         xValue := PADR( xValue , nWidth )
  70.  
  71.     CASE VALTYPE( xValue ) == "L"
  72.         xValue := PADR( IIF( xValue , "T" , "F" ) , nWidth )
  73.  
  74.     CASE VALTYPE( xValue ) == "A"
  75.         xValue := PADR( "ARRAY!" , nWidth )
  76.  
  77.     CASE VALTYPE( xValue ) == "M"
  78.         xValue := PADR( "MEMO" , nWidth )
  79.  
  80.     OTHERWISE   // just in case
  81.         xValue := PADR( STR( RECNO() ) , nWidth )
  82.  
  83. ENDCASE
  84.  
  85. RETURN( xValue )
  86. *
  87.