Contents of the FILEXIST.DOC file
The routine FILEXIST.BAS contains a Main section to do routine
QuickBASIC set up, and the subroutine DoesFileExist which
performs the following:
- sets up ax, cx, and dx input registers with dos service #,
type of file to search for, and current memory segment
& offset address
- calls of DOS Interrupt 21, service 4EH
- AND's (masks) the returned value of flag register with
1 hex to set or reset only the carry flag bit.
- assigns a value to a Boolean variable depending on value
of carry flag bit.
To test this routine in QuickBASIC environment:
Load QuickBASIC using the following line:
QB /L QB.QLB
Hit F5 to run
To include as a part of your source code:
* Load the program into which you wish to include this code
* Load the file FILEXIST.BAS into QB as a MODULE.
* Use cut/paste to transfer essential code.
a. move the declares, type/end type and dims as
b. transfer subroutine DoesFileExist to your pgm.
c. write appropriate code to test the value of
the exist Boolean returned by DoesFileExist and
branch to either a read or error routine.
d. unload the module FILEXIST.BAS
When compiling linking outside of QuickBASIC environment:
* use BC to compile
* when link prompts you for applicable libraries, type:
BCOM45.LIB + QB.LIB (for QB ver 4.5, .LIB optional)
This will link the call interrupt object code into your .EXE file
I pieced this routine together by combining bits and pieces from
a number of reference manuals. Using a standard DOS reference
manual, you should be able to take the basic concept here and
modify it to do all those slick things reserved for assembly
language programmers ! I have included good internal comments
to help you figure out whats going on.
Any comments or questions welcomed by :
Randy Sharpe, Compuserve # 72425,1247