[comp.lang.c] Help:Test if drive is ready in Turbo C

kji@vpnet.chi.il.us (Ken Isacson) (05/25/90)

Can anyone out there suggest some code in TURBO C that would do the 
following:

  1.  Detect if drive is ready with a disk.

That is is it.  I have tried using INT 13 with various variations, with
little success.  I am writting a program that is going to be reading
in info from a floppy drive, and if a disk is not inserted into the
drive and the drive door closed, the Abort, Retry, Ignore prompt comes
up and ruins my display.  There must be a much more graceful way
of doing this.

HINT - what I want is something similar to FastBack where it detects if
a disk has been changed, and then continues with the backup/restore
process.

Thanks in advance,
Ken

PS - to the person providing the best solution, they will receive a
     free registration to my product that is in developement!

reed@usceast.UUCP (Patrick Reed) (05/27/90)

In article <265ccb97-287comp.lang.c@vpnet.chi.il.us> kji@vpnet.chi.il.us (Ken Isacson) writes:
>
>Can anyone out there suggest some code in TURBO C that would do the 
>following:
>
>  1.  Detect if drive is ready with a disk.
>

[  stuff deleted about int 13 failing to handle the problem  ]

I have been faced with this problem in the past using Turbo C 1.5.
What you need is to establish your own hardware interrupt handler.
Turbo C provides some routines that may help:

harderr - establish a hardware error handler
hardresume - return to DOS from error handler
hardretn - return to application form error handler

Look in your reference manual for an example that covers this very problem.
It's been several years since I worked in this area, but from what I remember
there are a few problems:

1.  From within your error handler routine, you can only use dos calls
    1 through 0x0c, which means printf and the like are out.  This may 
    be ok for you if all you want to do is print a message in a box or
    something and you are sending your output to the video RAM (ie.
    not using the ROM BIOS calls).

2.  I seem to remember having some portability problems.  Having made the
    program detect the door being open on my machine and then testing it
    on some other machines, there seemed to be some inconsistent results.
    
Let me know if any of this helps.

Pat Reed   reed@usceast.cs.scarolina.edu