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

  1. /*
  2.  * File......: GETFILES.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_GETFILES()
  24.  *  $CATEGORY$
  25.  *      General
  26.  *  $ONELINER$
  27.  *      Create an array containing files matching a file spec
  28.  *  $SYNTAX$
  29.  *      GT_GetFiles( cDrive , cPath , cFileSpec )
  30.  *  $ARGUMENTS$
  31.  *      cDrive    - Drive to use
  32.  *      cPath     - Path to use
  33.  *      cFileSpec - File spec to find
  34.  *  $RETURNS$
  35.  *      A sorted array of file names
  36.  *  $DESCRIPTION$
  37.  *      Finds all files in the given path and returns them in a sorted array
  38.  *  $EXAMPLES$
  39.  *
  40.  *  $SEEALSO$
  41.  *
  42.  *  $INCLUDE$
  43.  *      GT_LIB.CH
  44.  *  $END$
  45.  */
  46.  
  47. *
  48. #include "GT_lib.ch"
  49.  
  50. FUNCTION GT_GetFiles( cDrive , cPath , cFileSpec )
  51.  
  52. /*****************************************************************************
  53.  Purpose - Create an array containing files matching given spec in given directory
  54.  Returns - Table name
  55.  Author  - Log
  56.  Created - 06/10/92
  57. ******************************************************************************
  58.  Parameters - cDrive    - Drive to use
  59.               cPath     - Path to use
  60.               cFileSpec - File spec to find
  61.  Privates   - None
  62.  Locals     - None
  63.  Externals  - None
  64. *****************************************************************************/
  65.  
  66. LOCAL aDir    := DIRECTORY( cDrive + ":" + cPath + "\" + cFileSpec )
  67. LOCAL aReturn := {}
  68. LOCAL nCount  := 0
  69.  
  70. FOR nCount := 1 TO LEN( aDir )
  71.     AADD( aReturn , LEFT( aDir[ nCount , 1 ] , AT( "." , aDir[nCount , 1 ] ) - 1 ) )
  72. NEXT nCount
  73.  
  74. RETURN ASORT( aReturn )
  75. *
  76.