home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / qb_pds / qb_sub / exist.sub < prev    next >
Encoding:
Text File  |  1987-07-14  |  3.0 KB  |  79 lines

  1. '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. '%  (C) 1987 HUMBLEWARE Custom Programming    Author: Lawrence A. Westhaver  %
  3. '%        247 Paul Martin Drive,  Baltimore MD  21227  (301) 799-1975        %
  4. '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  5. '%                                                                           %
  6. '%     FILENAME: EXIST.SUB                       LAST UPDATE: 05/24/1987     %
  7. '%                                                                           %
  8. '%  DESCRIPTION: Provides a simple method of determining if a file exists.   %
  9. '%                                                                           %
  10. '%         CALL: CALL EXIST(SEARCH$,RETCODE%)                                %
  11. '%                                                                           %
  12. '%       INPUTS: SEARCH$ = file to search for, may include drive and path.   %
  13. '%                                                                           %
  14. '%      OUTPUTS: RETCODE% = DOS return code found in the AX register.        %
  15. '%                                                                           %
  16. '%               Some of the possible       0 = file found                   %
  17. '%                         return codes:    3 = path not found               %
  18. '%                                         18 = file not found               %
  19. '%                                                                           %
  20. '%         NOTE: The Microsoft QuickBASIC INT86 assembly routine must be     %
  21. '%               linked into your program at compile time or it must be      %
  22. '%               present in the QuickBASIC USERLIB.EXE file before this      %
  23. '%               routine can be used.                                        %
  24. '%                                                                           %
  25. '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  26.  
  27.  
  28. SUB EXIST(SEARCH$,RETCODE%) Static
  29.  
  30.  
  31. 'dim parameter storage for INT86 call
  32.  
  33.     DIM PARMIN%(7),PARMOUT%(7)
  34.  
  35.  
  36. 'declare indexes for INT86 calls
  37.  
  38.     AXREG%=0    'AX register
  39.     BXREG%=1    'BX register
  40.     CXREG%=2    'CX register
  41.     DXREG%=3    'DX register
  42.     BPREG%=4    'BP register
  43.     SIREG%=5    'SI register
  44.     DIREG%=6    'DI register
  45.     FLAGS%=7    'Flags
  46.  
  47.  
  48. 'define disk transfer area
  49.  
  50.     DTA$=STRING$(44," ")+""
  51.  
  52.  
  53. 'set disk transfer area
  54.  
  55.     PARMIN%(AXREG%)=&H1A00      'select dos function 26
  56.     PARMIN%(DXREG%)=SADD(DTA$)  'get DTA address into reg.
  57.     CALL INT86(&H21,VARPTR(PARMIN%(0)),VARPTR(PARMOUT%(0)))
  58.  
  59.  
  60. 'convert search string to asciiz string
  61.  
  62.     SEARCH$=SEARCH$+CHR$(0)
  63.  
  64.  
  65. 'find first file
  66.  
  67.     PARMIN%(AXREG%)=&H4E00          'select dos function 78
  68.     PARMIN%(CXREG%)=&H0000          'search for only normal files
  69.     PARMIN%(DXREG%)=SADD(SEARCH$)   'get address search string into reg.
  70.     CALL INT86(&H21,VARPTR(PARMIN%(0)),VARPTR(PARMOUT%(0)))
  71.  
  72.  
  73. 'set return code
  74.  
  75.     RETCODE%=PARMOUT%(AXREG%)
  76.  
  77.  
  78. END SUB 'exist
  79.