home *** CD-ROM | disk | FTP | other *** search
/ DOS Wares / doswares.zip / doswares / DATABASE / DBASE5 / CUA_SAMP.ZIP / BLDDIRS.PRG < prev    next >
Encoding:
Text File  |  1994-06-24  |  1.9 KB  |  62 lines

  1. PROCEDURE BldDirs
  2. PARAMETERS poListBox
  3. *----------------------------------------------------------------------------
  4. * NAME
  5. *   BldDirs - Build a list of directories then set the DataSource.  This
  6. *             routine can be used whenever a listbox of directories from
  7. *             the current directory is needed.
  8. *
  9. * PARAMETERS
  10. *   poListBox  = Object ref to list box or combo box.
  11. *
  12. *----------------------------------------------------------------------------
  13.     PRIVATE cPath, n, i, nDirs, nMod, nOk
  14.  
  15.     cPath = SET( "DIRECTORY" )
  16.     IF RIGHT( m->cPath, 1 ) <> "\"
  17.         cPath = m->cPath + "\"
  18.     ENDIF
  19.  
  20.     *--------------------------------
  21.     *-- Build the list of directories
  22.     *--------------------------------
  23.     DECLARE dB5___OFls[1,5]
  24.     n = ADIR( dB5___OFls, m->cPath + "*.*", "D" )
  25.  
  26.     n = MAX( 1, m->n )
  27.     nDirs = 0
  28.     DECLARE dB5___Dir[m->n]
  29.  
  30.     FOR i = 1 TO m->n
  31.         IF dB5___OFls[ m->i, 5 ] = "....D."
  32.             nDirs = m->nDirs + 1
  33.             dB5___Dir[ m->nDirs ] = dB5___OFls[ m->i, 1 ]
  34.         ENDIF
  35.     ENDFOR
  36.  
  37.     *---------------------------------------------------------------
  38.     *-- Chop the original size down to adjust the filled directories
  39.     *-- and sort the result.
  40.     *---------------------------------------------------------------
  41.     DO CASE
  42.         CASE m->nDirs = 1
  43.             poListBox.DataSource = "ARRAY dB5___Dir"
  44.         CASE nDirs > 1
  45.             nMod = ARESIZE( dB5___Dir, m->nDirs )
  46.             nOk = ASORT( dB5___Dir )
  47.             IF LEFT( db5___Dir[1], 1 ) = "."
  48.                 IF db5___Dir[1] = ".." .OR. db5___Dir[2] = ".."
  49.                     db5___Dir[1] = "\"
  50.                     db5___Dir[2] = ".."
  51.                 ENDIF
  52.             ENDIF
  53.             poListBox.DataSource = "ARRAY dB5___Dir"
  54.         CASE nDirs < 1
  55.             poListBox.DataSource = "STRING \"
  56.     ENDCASE
  57.  
  58. RETURN
  59. *-- EOP: BldDirs
  60.  
  61.  
  62.