home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / homonlib.zip / DIREXIST.BAS < prev    next >
BASIC Source File  |  1995-04-13  |  1KB  |  47 lines

  1. DEFINT A-Z
  2.  
  3. ' $INCLUDE: 'TRUEFALS.INC'
  4. ' $INCLUDE: 'DIR.INC'
  5.  
  6. DECLARE FUNCTION DirExist (dirname$)
  7.  
  8. FUNCTION DirExist (dirname$)
  9. '****************************************************************************
  10. 'The function will return TRUE if the directory in question exists, FALSE
  11. ' otherwise.
  12. '
  13. 'The dirname$ argument may be passed with or without a trailing backslash.
  14. '
  15. 'Note: A null string passed to the function will be interpreted as the
  16. ' current directory and the function will return TRUE.
  17. '
  18. 'Caution:  Attempting to use this function on an empty diskette drive will
  19. ' hang your computer.  Make sure there is a disk inserted first.
  20. '
  21. 'See function MakeDir() for an example of use.
  22. '
  23. '****************************************************************************
  24.  
  25. IF LEN(dirname$) = 0 THEN               'Assume a null string is referring to
  26.      DirExist = TRUE                    'the current directory and return
  27. END IF                                  'TRUE.
  28.  
  29. DIM DirInfo AS DirType
  30.  
  31. bs$ = "\"
  32.  
  33. d$ = dirname$                           'Don't alter the original.
  34.  
  35. IF RIGHT$(d$, 1) <> bs$ THEN            'Add a trailing backslash if needed.
  36.      d$ = d$ + bs$
  37. END IF
  38.  
  39. d$ = d$ + "*.*"
  40.  
  41. f$ = Dir$(d$, DirInfo)                  'See if there is anything there...
  42.  
  43. IF LEN(f$) AND DirInfo.ErrorCode = 0 THEN DirExist = TRUE
  44.  
  45. END FUNCTION
  46.  
  47.