home *** CD-ROM | disk | FTP | other *** search
- ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;
- ; Name : DOESFILE.ASM
- ;
- ; Revised : 01-29-91 11:56am
- ;
- ; Overview : This routine checks for the existence of the file specified
- ; and returns an INTEGER value of -1 (TRUE) if the file exists,
- ; or an INTEGER value of 0 (FALSE) if the file does not exist.
- ; Note that this routine will find a file even if it is "hidden"
- ; or "read-only" or "system" - the file attribute value makes no
- ; difference.
- ;
- ; Notes : - Requires the Microsoft MACRO ASSEMBLER V 5.1 or higher for
- ; successful assembly due to the use of the Microsoft simplified
- ; Segment Model.
- ; - This routine should be DECLAREd as an external FUNCTION
- ; routine with the QuickBASIC statement -
- ;
- ; DECLARE FUNCTION DoesFileExist%( FileName AS STRING )
- ;
- ; which allows the rest of your program to use this FUNCTION as
- ; per the following example:
- ;
- ; IF DoesFileExist%( FileName$ + CHR$(0) ) = TRUE THEN...
- ;
- ; Parameters : One parameter is required here, which is the name of the file
- ; for which to check. This may be a pre-defined STRING VARIABLE,
- ; or an IMMEDIATE STRING.
- ; NOTE: The FileName$ parameter may include a DOS drive and
- ; path specifier if you wish.
- ; NOTE: The FileName$ MUST END with a CHR$(0) character
- ;
- ;==============================================================================
- .MODEL MEDIUM, BASIC
- .CODE
-
- DoesFileExist PROC FILENAME:WORD
-
- mov BX,FILENAME ; Put address of the FileName into BX
- mov DX,[BX+2] ; Note that DS:DX now points at the
- ; start of ASCIIZ string
-
- mov CX,16h ; Find the file no matter what
- ; DOS file attribute it has
- mov AX,04E00h ; DOS "FindFirst Match" service
- int 21h
-
- jnc FoundTheFile
- xor AX,AX ; If CARRY set, make AX = 0 = FALSE
- ; (not found) for RETURN value
- jmp short ExitDoesFileExist ; If CARRY is clear, then file exists
-
- FoundTheFile:
- mov AX,-1 ; File was found, so make AX = -1
- ; = TRUE for RETURN value
-
- ExitDoesFileExist:
- ret ; Back to the QB calling program
-
- DoesFileExist ENDP
- END
- ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-