{***********************************************************************}
{									}
{ __StrErUtl  Return DOS error description				}
{									}
{ function  __StrErUtl(ErrorCode : word) : string;			}
{									}
{	      ErrorCode The value of the DOS error code whose string	}
{			description is to be returned.			}
{									}
{ Description The purpose of this function is to provide a text string	}
{	      description of a given DOS error code encountered during	}
{	      DOS calls or critical erros.				}
{									}
{	      Notice that inclusion of this procedure will add over 2K	}
{	      of constants to the code segment because the constants	}
{	      are stored in the code segment.  The reason for using	}
{	      the tedious initialization rather than a typed constant	}
{	      is that type constants are stored in the data segment	}
{	      whether the function is used or not.  Therefore there	}
{	      would be a 2K overhead whenever this unit is used, even	}
{	      if __StrErUtl is not called.  Because this function is	}
{	      only called during error conditions, the overhead in	}
{	      execution speed and code size is much more tolerable than }
{	      usage of the limited data segment (limited to 64K).	}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc. 1987		}
{_______________________________________________________________________}

function __StrErUtl(ErrorCode : word) : string;

  const
    ERRSTRLEN	 = 35;

  type
    ErrorCodeStr = array[-1..68] of string[ERRSTRLEN];

  var
    StrIndex : integer;
    ErrorStr : ErrorCodeStr;

  begin {__StrErUtl}

    ErrorStr[-1] := 'Unknown DOS error';		    { Reserved	}
    ErrorStr[ 0] := 'No error encountered';		    { Code =  0 }
    ErrorStr[ 1] := 'Invalid function number';		    { Code =  1 }
    ErrorStr[ 2] := 'File not found';			    { Code =  2 }
    ErrorStr[ 3] := 'Path not found';			    { Code =  3 }
    ErrorStr[ 4] := 'Too many open files (no handles)';     { Code =  4 }
    ErrorStr[ 5] := 'Access denied';			    { Code =  5 }
    ErrorStr[ 6] := 'Invalid handle number';		    { Code =  6 }
    ErrorStr[ 7] := 'Memory control block destroyed';	    { Code =  7 }
    ErrorStr[ 8] := 'Insufficient memory';		    { Code =  8 }
    ErrorStr[ 9] := 'Invalid memory block address';	    { Code =  9 }
    ErrorStr[10] := 'Invalid environment';		    { Code = 10 }
    ErrorStr[11] := 'Invalid format';			    { Code = 11 }
    ErrorStr[12] := 'Invalid access code';		    { Code = 12 }
    ErrorStr[13] := 'Invalid data';			    { Code = 13 }
    ErrorStr[14] := 'Internal error - reserved';	    { Code = 14 }
    ErrorStr[15] := 'Invalid drive number specified';	    { Code = 15 }
    ErrorStr[16] := 'Cannot remove current directory';	    { Code = 16 }
    ErrorStr[17] := 'Device names are different';	    { Code = 17 }
    ErrorStr[18] := 'No more matching files found';	    { Code = 18 }
    ErrorStr[19] := 'Diskette is write-protected';	    { Code = 19 }
    ErrorStr[20] := 'Unknown unit';			    { Code = 20 }
    ErrorStr[21] := 'Drive not ready';			    { Code = 21 }
    ErrorStr[22] := 'Unknown command';			    { Code = 22 }
    ErrorStr[23] := 'Data error (CRC error)';		    { Code = 23 }
    ErrorStr[24] := 'Bad request structure length';	    { Code = 24 }
    ErrorStr[25] := 'Seek error';			    { Code = 25 }
    ErrorStr[26] := 'Unknown media type';		    { Code = 26 }
    ErrorStr[27] := 'Sector not found'; 		    { Code = 27 }
    ErrorStr[28] := 'Printer out of paper';		    { Code = 28 }
    ErrorStr[29] := 'Write fault';			    { Code = 29 }
    ErrorStr[30] := 'Read fault';			    { Code = 30 }
    ErrorStr[31] := 'General failure';			    { Code = 31 }
    ErrorStr[32] := 'Sharing violation';		    { Code = 32 }
    ErrorStr[33] := 'Lock violation';			    { Code = 33 }
    ErrorStr[34] := 'Invalid disk change';		    { Code = 34 }
    ErrorStr[35] := 'No more file control blocks left';     { Code = 35 }
    ErrorStr[36] := 'Sharing buffer overflow';		    { Code = 36 }
    ErrorStr[37] := 'Network request not supported';	    { Code = 50 }
    ErrorStr[38] := 'Remote computer not listening';	    { Code = 51 }
    ErrorStr[39] := 'Duplicate name on network';	    { Code = 52 }
    ErrorStr[40] := 'Network name not found';		    { Code = 53 }
    ErrorStr[41] := 'Network busy';			    { Code = 54 }
    ErrorStr[42] := 'network device no longer exists';	    { Code = 55 }
    ErrorStr[43] := 'Net BIOS command limit exceeded';	    { Code = 56 }
    ErrorStr[44] := 'Network adapter hardware error';	    { Code = 57 }
    ErrorStr[45] := 'Incorrect response from network';	    { Code = 58 }
    ErrorStr[46] := 'Unexpected network error'; 	    { Code = 59 }
    ErrorStr[47] := 'Incompatible remote adapter';	    { Code = 60 }
    ErrorStr[48] := 'Print queue full'; 		    { Code = 61 }
    ErrorStr[49] := 'Not enough space for print file';	    { Code = 62 }
    ErrorStr[50] := 'Print file was deleted';		    { Code = 63 }
    ErrorStr[51] := 'Network name was deleted'; 	    { Code = 64 }
    ErrorStr[52] := 'Access denied';			    { Code = 65 }
    ErrorStr[53] := 'Network device type incorrect';	    { Code = 66 }
    ErrorStr[54] := 'Network name not found';		    { Code = 67 }
    ErrorStr[55] := 'Network name limit exceeded';	    { Code = 68 }
    ErrorStr[56] := 'Net BIOS session limit exceeded';	    { Code = 69 }
    ErrorStr[57] := 'Temporarily paused';		    { Code = 70 }
    ErrorStr[58] := 'Network request not accepted';	    { Code = 71 }
    ErrorStr[59] := 'Print or disk redirection is paused';  { Code = 72 }
    ErrorStr[60] := 'File already exists';		    { Code = 80 }
    ErrorStr[61] := 'Internal error - reserved';	    { Code = 81 }
    ErrorStr[62] := 'Cannot make directory entry';	    { Code = 82 }
    ErrorStr[63] := 'Fail on INT 24';			    { Code = 83 }
    ErrorStr[64] := 'Too many redirections';		    { Code = 84 }
    ErrorStr[65] := 'Duplicate redirection';		    { Code = 85 }
    ErrorStr[66] := 'Invalid passward'; 		    { Code = 86 }
    ErrorStr[67] := 'Invalid parameter';		    { Code = 87 }
    ErrorStr[68] := 'Network device fault';		    { Code = 88 }

    case ErrorCode of
       0..36 : StrIndex := ErrorCode;
      37..49 : StrIndex := -1;
      50..72 : StrIndex := ErrorCode - 13;
      73..79 : StrIndex := -1;
      80..88 : StrIndex := ErrorCode - 20;
      else
	 StrIndex := 255;
    end; {case ErrorCode}

    if (StrIndex < 255) then
       __StrErUtl := ErrorStr[StrIndex]
    else
       __StrErUtl := 'Unknown DOS error'

  end;	{__StrErUtl}
