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

  1. /*
  2.     File......: GT_a2Str.prg
  3.     Author....: Martin Bryant
  4.     BBS.......: The Dark Knight Returns
  5.     Net/Node..: 050/069
  6.     User Name.: Martin Bryant
  7.     Date......: 04/02/93
  8.     Revision..: 1.0
  9.  
  10.     This is an original work by Martin Bryant and is placed
  11.     in the public domain.
  12.  
  13.     Modification history:
  14.     ---------------------
  15.  
  16.     Rev 1.0 04/02/93
  17.     PD Revision.
  18. */
  19.  
  20. /*  $DOC$
  21.  *  $FUNCNAME$
  22.  *      GT_A2STR()
  23.  *  $CATEGORY$
  24.  *      Array
  25.  *  $ONELINER$
  26.  *      Convert an array into a character string
  27.  *  $SYNTAX$
  28.  *      GT_a2Str(<aData>,<bConvert>,<nLength>) -> cData
  29.  *  $ARGUMENTS$
  30.  *      <aData> is the array of data. <bConvert> must be
  31.  *      able to handle all data types found in the array.
  32.  *
  33.  *      <bConvert> is the Block function to convert the data
  34.  *      from the array. This data will then be padded to
  35.  *      <nLength> by the GT_a2Str().
  36.  *
  37.  *      <nLength> is the length to pad the items to in the
  38.  *      string.
  39.  *  $RETURNS$
  40.  *      cData
  41.  *  $DESCRIPTION$
  42.  *      To turn an array into a character string, for saving to a
  43.  *      mem file etc.
  44.  *  $EXAMPLES$
  45.  *      // Convert number  array to a string.
  46.  *      aData := {0,2,7,51,9,4}
  47.  *      cData := GT_a2Str(aData,{ | nVal | Str(nVal) },2)
  48.  *      // Result is " 0 2 751 9 4"
  49.  *  $SEEALSO$
  50.  *
  51.  *  $INCLUDE$
  52.  *
  53.  *  $END$
  54.  */
  55.  
  56. #include "GT_LIB.ch"
  57.  
  58. FUNCTION GT_a2Str(aData,bConvert,nLength)
  59.  
  60. Local cData := ''
  61. Local nCount := 0
  62. Local nItems := 0
  63.  
  64. Default aData to {}
  65. Default bConvert to { | uData | uData }
  66. Default nLength to 1
  67.  
  68. nItems := LEN(aData)
  69.  
  70. FOR nCount := 1 TO nItems
  71.  
  72.     cData += PADR(EVAL(bConvert,aData[nCount]),nLength)
  73.  
  74. NEXT
  75.  
  76. /*
  77.     End of GT_a2Str()
  78. */
  79. RETURN(cData)
  80.