home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / pascal / rehack / convers / ioerror.pas next >
Encoding:
Pascal/Delphi Source File  |  1993-04-14  |  4.4 KB  |  131 lines

  1. {
  2. *******************************************************
  3.  
  4.         Turbo Pascal Version 5.5
  5.         IO Error Messages
  6.  
  7.         Copyright (c) 1993 Mark Baker
  8. *******************************************************
  9. }
  10.  
  11. unit IOError;
  12.  
  13. interface
  14.  
  15.   const
  16.  
  17.     Success        = 0;
  18.     DOS_Error      = 1;
  19.     IO_Error       = 2;
  20.     Critical_Error = 3;
  21.     Unknown_Error  = 255;
  22.  
  23.     File_not_found                     = 2;
  24.     Path_not_found                     = 3;
  25.     Too_many_open_files                = 4;
  26.     File_access_denied                 = 5;
  27.     Invalid_file_handle                = 6;
  28.     Invalid_file_access_code           = 12;
  29.     Invalid_drive_number               = 15;
  30.     Cannot_remove_current_directory    = 16;
  31.     Cannot_rename_across_drives        = 17;
  32.     Disc_read_error                    = 100;
  33.     Disc_write_error                   = 101;
  34.     File_not_assigned                  = 102;
  35.     File_not_open                      = 103;
  36.     File_not_open_for_input            = 104;
  37.     File_not_open_for_output           = 105;
  38.     Invalid_numeric_format             = 106;
  39.     Disc_is_write_protected            = 150;
  40.     Unknown_unit                       = 151;
  41.     Drive_not_ready                    = 152;
  42.     Unknown_command                    = 153;
  43.     CRC_error_in_data                  = 154;
  44.     Bad_drive_request_structure_length = 155;
  45.     Disc_seek_error                    = 156;
  46.     Unknown_media_type                 = 157;
  47.     Sector_not_found                   = 158;
  48.     Printer_out_of_paper               = 159;
  49.     Device_write_fault                 = 160;
  50.     Device_read_fault                  = 161;
  51.     Hardware_failure                   = 162;
  52.  
  53.  
  54.   procedure IOError_Message
  55.             (Error_Code : byte; var Error_Message : string;
  56.              var Error_Type : byte);
  57.  
  58.  
  59. implementation
  60.  
  61.   const
  62.  
  63.     DOS_Errors      : array[2..17] of string[34] =
  64.                       ('File not found',
  65.                        'Path not found',
  66.                        'Too many open files',
  67.                        'File access denied',
  68.                        'Invalid file handle',
  69.                        '','','','','',
  70.                        'Invalid file access code',
  71.                        '','',
  72.                        'Invalid drive number',
  73.                        'Cannot remove current directory',
  74.                        'Cannot rename across drives');
  75.     IO_Errors       : array[100..106] of string[34] =
  76.                       ('Disc read error',
  77.                        'Disc write error',
  78.                        'File not assigned',
  79.                        'File not open',
  80.                        'File not open for input',
  81.                        'File not open for output',
  82.                        'Invalid numeric format');
  83.     Critical_Errors : array[150..162] of string[34] =
  84.                       ('Disc is write-protected',
  85.                        'Unknown unit',
  86.                        'Drive not ready',
  87.                        'Unknown command',
  88.                        'CRC error in data',
  89.                        'Bad drive request structure length',
  90.                        'Disc seek error',
  91.                        'Unknown media type',
  92.                        'Sector not found',
  93.                        'Printer out of paper',
  94.                        'Device write fault',
  95.                        'Device read fault',
  96.                        'Hardware failure');
  97.     Unknown_Error_Message = 'Unknown Error';
  98.  
  99.  
  100.   procedure IOError_Message
  101.             (Error_Code : byte; var Error_Message : string;
  102.              var Error_Type : byte);
  103.   begin
  104.     case Error_Code of
  105.       0        : begin
  106.                    Error_Type:=Success;
  107.                    Error_Message:='';
  108.                  end;
  109.       2..6,
  110.       12,
  111.       15..17   : begin
  112.                    Error_Type:=DOS_Error;
  113.                    Error_Message:=DOS_Errors[Error_Code];
  114.                  end;
  115.       100..106 : begin
  116.                    Error_Type:=IO_Error;
  117.                    Error_Message:=IO_Errors[Error_Code];
  118.                  end;
  119.       150..162 : begin
  120.                    Error_Type:=Critical_Error;
  121.                    Error_Message:=Critical_Errors[Error_Code];
  122.                  end;
  123.       else begin
  124.              Error_Type:=Unknown_Error;
  125.              Error_Message:=Unknown_Error_Message;
  126.            end;
  127.     end;
  128.   end; { IOError_Message }
  129.  
  130. end.
  131.