home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / basic / bmag / existfun.bas < prev    next >
Encoding:
BASIC Source File  |  1994-04-26  |  1.6 KB  |  40 lines

  1. '─ Area: F-QUICKBASIC ─────────────────────────────────────────────────────────
  2. '  Msg#: 390                                          Date: 16 Apr 94  23:25:02
  3. '  From: Joe Negron                                   Read: Yes    Replied: No 
  4. '    To: Todd Jacobs                                  Mark:                     
  5. '  Subj: Checking to see if a dir
  6. '──────────────────────────────────────────────────────────────────────────────
  7. 'TJ> I have been unable to figure out a way to make QuickBasic check to
  8. '  > see if a  directory exists.  There's no "IF EXIST" function, and FILES
  9. '  > doesn't do  anything along those lines.
  10.  
  11. DEFINT A-Z
  12.  
  13. '$INCLUDE: 'qb.bi'
  14.  
  15. DECLARE FUNCTION Exist% (FileName$)
  16.  
  17. '***********************************************************************
  18. '* FUNCTION Exist%
  19. '*
  20. '* PURPOSE
  21. '*    Uses DOS ISR 21H, Function 4EH (Find First Matching Directory
  22. '*    Entry) to determine the existence of FileName$.
  23. '***********************************************************************
  24. FUNCTION Exist% (FileName$) STATIC
  25.    DIM Reg AS RegTypeX
  26.  
  27.    Reg.ax = &H4E00
  28.    Reg.cx = &H3F                             'search for all files
  29.    FileName$ = FileName$ + CHR$(0)           'must end with null byte
  30.  
  31.    Reg.ds = VARSEG(FileName$)                'load DS:DX with
  32.    Reg.dx = SADD(FileName$)                  '  address of FileName$
  33.  
  34.    InterruptX &H21, Reg, Reg
  35.    Exist% = Reg.ax = 0                       'if ax contains a value,
  36.                                              '  then file does not exist
  37.    'remove the null byte
  38.    FileName$ = LEFT$(FileName$, LEN(FileName$) - 1)
  39. END FUNCTION
  40.