Draft: How can I test if a disk is present in the drive? 
Author Message
 Draft: How can I test if a disk is present in the drive?

118. *****
 Q: How can I test if a disk is present in the drive?

 A: Below is the code
  uses Dos;
  (* Test if a drive is ready. The default drive is denoted by '0' *)
  function INDRIVFN (drive : char) : boolean;
  var regs : registers;
      dnum : word;
  begin
    drive := Upcase (drive);
    if drive = '0' then
       dnum := 0
     else
       begin
         case drive of
           'A'..'Z' : ;
           else begin indrivfn := false; exit; end;
         end;  {case}
         dnum := ord(drive) - ord('A') + 1;
       end;
    FillChar (regs, SizeOf(regs), 0);
    regs.ah := $1C;
    regs.dl := dnum;
    Intr ($21, regs);
    indrivfn := regs.al <> $FF;
  end;  (* indrivfn *)

   All the best, Timo

....................................................................

Moderating at ftp:// & http://www.*-*-*.com/ archives  193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa

Spam foiling in effect.  My email filter autoresponder will return a
required email password to users not yet in the privileges database.



Wed, 18 Jun 1902 08:00:00 GMT  
 Draft: How can I test if a disk is present in the drive?



Quote:
>118. *****
> Q: How can I test if a disk is present in the drive?

> A: Below is the code
>  uses Dos;
>  (* Test if a drive is ready. The default drive is denoted by '0' *)
>  function INDRIVFN (drive : char) : boolean;
>  var regs : registers;
>      dnum : word;
>  begin
>    drive := Upcase (drive);
>    if drive = '0' then
>       dnum := 0
>     else
>       begin
>         case drive of
>           'A'..'Z' : ;
>           else begin indrivfn := false; exit; end;
>         end;  {case}

  if not (drive in ['A'..'Z']) then begin indrivfn := false; exit; end;
  uses one instruction fewer, and is, IMHO, clearer.

Quote:
>         dnum := ord(drive) - ord('A') + 1;
>       end;
>    FillChar (regs, SizeOf(regs), 0);
>    regs.ah := $1C;
>    regs.dl := dnum;
>    Intr ($21, regs);

  MsDos(regs) ;
  uses one instruction fewer.

Quote:
>    indrivfn := regs.al <> $FF;
>  end;  (* indrivfn *)

The code returns TRUE for a RAMdrive - in which no disc is actually
present - and FALSE for drives that one does not have.  Clearly this is
the best it can do.

I have 5 physical drives :
  A=1.44MB, B=1.2MB, C=IDE, D&E are Tandon PacII removables.
  F is RAMdrive
  G is A again
  H is B again.

It seems to answer correctly throughout - HOWEVER, running it in the
BP7.01 IDE, Real mode, in a WfWg3.11 windowed DOS box, the window
sometimes goes full-screen, even when not doing A<->G / B<->H.

Regards,

--

  Web URL: http://www.merlyn.demon.co.uk/ - FAQqish topics, acronyms and links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
  Before a reply, quote with ">" / "> ", known to good news readers (SoRFC1036)



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. table updates present, but not presented in editbox/DBCtrlGrid after closing and reopening application

2. BDE, No disk in drive A

3. TEST TEST TEST TEST

4. 2 disk drive questions

5. Disk Drive Controller Programming

6. Display Free Hard Disk Size Of SCSI Hard Drive

7. How to check to see if a disk is in drive a:

8. Displaying PCX or BMP @ 640x480x256 + detecting disk drives?

9. Test Drive 1500 of the Best Software Titles

10. Testing Directory path on read only drive

11. Windows: Test for Disk

12. It's not bad canned meat...

 

 
Powered by phpBB® Forum Software