Dec 132017
 
Quick Basic source code that checks to see if a file exists.
File FILEEXST.ZIP from The Programmer’s Corner in
Category BASIC Language
Quick Basic source code that checks to see if a file exists.
File Name File Size Zip Size Zip Type
FILEXIST.BAS 6960 2590 deflated
FILEXIST.DOC 2452 1007 deflated
TPCREAD.ME 199 165 deflated

Download File FILEEXST.ZIP Here

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
into QuickBASIC
* 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
necessary.
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





 December 13, 2017  Add comments

Leave a Reply