home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / TURBOP.ZIP / DRIVEERR.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-11-01  |  4.0 KB  |  108 lines

  1. {             Program to solve drive errors on IBM PC
  2.                      Code by Marshall Brain.
  3.  
  4.     The short program contained in this file demonstrates the use
  5. of a procedure that will detect disk errors on the
  6. IBM PC when the drive door is left open. It eliminates the
  7. annoying "abort, retry, ignore?" message generated by DOS for
  8. disk door errors. For example, when using the techniques shown here,
  9. you will get an I/O error of 01 if you attempt to reset a file with
  10. the drive door open, and an F0 if you try to rewrite a file with the
  11. door open. You read these values out of the IOresult variable just
  12. as you normally would, using $I- and $I+.
  13.     To use the technique shown here in your own programs, you
  14. will need to do two things. First, you must copy BOTH the "setup"
  15. procedure and the "int24" procedure into your program. Then you
  16. must call "setup" before the int24 procedure will be effective.
  17. "Setup" redirects DOS to the int24 procedure to handle errors. You
  18. must also insure that "int24" is never swapped out in an overlay,
  19. or the program will blow up. Please note that "setup" uses the "y"
  20. variable to pick up the code segment location. You can use this
  21. technique, or any other that you prefer. I just know that this
  22. one works.
  23.     To run the example program given here, create a file called
  24. "door.chk" on drive A: and run the program. It will work fine, and
  25. reset the file with no problem. Then try leaving the drive door
  26. open. After about 5 seconds, you will get the message that the door
  27. is open, or that the file doesn't exist.
  28.     This technique isn't perfect - on file reading, you
  29. only know whether the file is there OR that the door is open.
  30. You never know which it is. On file writing you know that the door
  31. is open, OR that the disk is full, but never which one. Also Note
  32. that the DOS printer error  gets tossed back to you by this
  33. routine, so keep that in mind.
  34.     For me, this program is not perfect, but better than nothing. I
  35. hope it is helpful.   -MB}
  36.  
  37.     program int24tst;
  38.     const
  39.       y : integer = 0;
  40.     var
  41.       fileptr:text;
  42.  
  43.     procedure int24;
  44.     {To understand this routine, you will need to read}
  45.     {the description on Interrupt 24 in the DOS manual}
  46.     begin
  47.       inline
  48.        ($58/   {POP AX  Discard first 3 words on stack}
  49.         $58/   {POP AX    }
  50.         $58/   {POP AX    }
  51.         $58/   {POP AX  Pop all registers}
  52.         $5b/   {POP BX    }
  53.         $59/   {POP CX    }
  54.         $5a/   {POP DX    }
  55.         $5e/   {POP SI    }
  56.         $5f/   {POP DI    }
  57.         $5d/   {POP BP    }
  58.         $1f/   {POP DS    }
  59.         $07/   {POP ES    }
  60.         $cf);  {IRET    Return to next instruction}
  61.     end;
  62.  
  63.     procedure setup;
  64.     {Change interrupt vector 24 to point to the int24 procedure}
  65.     var result : record ax,bx,cx,dx,bp,si,di,ds,es,flags:integer; end;
  66.     begin
  67.       result.ds:=seg(y); {typed constants are stored in code seg}
  68.       result.dx:=ofs(int24)+7;
  69.       result.ax:=$2524;
  70.       intr($21,result);
  71.     end;
  72.  
  73.     begin
  74.       setup;
  75.       assign(fileptr,'a:door.chk');
  76.       {$I-}
  77.       reset(fileptr);
  78.       {$I+}
  79.       if IOresult<>0 then
  80.         writeln('Either the drive door is open, or DOOR.CHK does not exist');
  81.       close(fileptr);
  82.     end.
  83. ard first 3 words on stack}
  84.         $58/   {POP AX    }
  85.         $58/   {POP AX    }
  86.         $58/   {POP AX  Pop all registers}
  87.         $5b/   {POP BX    }
  88.         $59/   {POP CX    }
  89.         $5a/   {POP DX    }
  90.         $5e/   {POP SI    }
  91.         $5f/   {POP DI    }
  92.         $5d/   {POP BP    }
  93.         $1f/   {POP DS    }
  94.         $07/   {POP ES    }
  95.         $cf);  {IRET    Return to next instruction}
  96.     end;
  97.  
  98.     procedure setup;
  99.     {Change interrupt vector 24 to point to the int24 procedure}
  100.     var result : record ax,bx,cx,dx,bp,si,di,ds,es,flags:integer; end;
  101.     begin
  102.       result.ds:=seg(y); {typed constants are stored in code seg}
  103.       result.dx:=ofs(int24)+7;
  104.       result.ax:=$2524;
  105.       intr($21,result);
  106.     end;
  107.  
  108.     begi