home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / microcrn / issue_49.arc / IOHANDLR.PAS < prev    next >
Pascal/Delphi Source File  |  1989-07-11  |  2KB  |  77 lines

  1. { Micro Cornucopia Magazine - Issue #49
  2.   TidBits Figure 1 - Turbo Pascal objects }
  3.  
  4. unit my_io_handler;
  5.  
  6. interface
  7.  
  8. type
  9.  
  10. Prompt = string[80];
  11.  
  12. my_io_handler = object
  13.   IOErr : boolean;
  14.   IOCode: integer;
  15.   constructor init;
  16.   procedure report(Msg : Prompt); virtual;
  17.   procedure IOCheck; virtual;
  18. end;
  19.  
  20. implementation
  21.  
  22. uses
  23.   DOS,
  24.   Unit_win,
  25.   Crt;
  26.  
  27. constructor my_io_handler.init;
  28. begin {this is all we have to do: TP handles the work.}
  29. end;
  30.  
  31. procedure my_io_handler.IOCheck;
  32. begin
  33.   IOCode := IOResult;
  34.   IOErr := (IOCode <> 0);
  35.   if IOErr then
  36.     begin
  37.      case IOCode of
  38.        $02 : report('File not found');
  39.        $03 : report('Path not found');
  40.        $04 : report('File not open');
  41.        $10 : report('Error in numeric format');
  42.        $20 : report('Operation not allowed on logical device');
  43.        $21 : report('Not allowed in direct mode');
  44.        $22 : report('Assign to standard files not allowed');
  45.        $90 : report('Record length mismatch');
  46.        $91 : report('Seek beyond EOF');
  47.        $99 : report('Unexpected EOF');
  48.        $F0 : report('Disk write error');
  49.        $F1 : report('Directory is full');
  50.        $F2 : report('File size overflow');
  51.        $F3 : report('Too many open files');
  52.        $FF : report('File disappeared')
  53.        else
  54.          report('Unknown I/O error: ');
  55.          write(IOCode:3);
  56.     end {case}
  57.   end {if}
  58. end; {IOCheck}
  59.  
  60. procedure my_io_handler.report(Msg : Prompt);
  61.  
  62. var
  63.    F : text;
  64.    FileName, P : string;
  65.    W1 : _WindowPtr;
  66.    Window_status : boolean;
  67.    C : char;
  68.  
  69. begin
  70.   W1 := __MakeWin(3,5,74,18,22,20,Black,LightGray,
  71.         _DLBORD_WIN,LightRed,Black);
  72.   Window_status := __DispWin(W1);
  73.   writeln(Msg);
  74.   C := readkey;
  75.   Window_status := __RemWin;
  76. end;
  77.