{***********************************************************************}
{									}
{ __RetErUtl  Return DOS error extended information			}
{									}
{ function  __RetErUtl(var Class,Action,Locus : word) : word;		}
{									}
{	      Class	The returned error class.			}
{	      Action	The returned suggested action code.		}
{	      Locus	The returned locus (or area) of the error.	}
{									}
{ Description The purpose of this function is to provide more detail of }
{	      error conditions which may occur during DOS function	}
{	      calls and critical errors.  The function returns the last }
{	      DOS error encountered as the function value by invoking	}
{	      DOS function $59. Therefore, this function is valid only	}
{	      for DOS 3.00 or later. For earlier versions, the function }
{	      value returned is zero, and Class, Action and Locus are	}
{	      set to zero.						}
{									}
{	      For a description of the values for the Class, Action and }
{	      Locus, see the DOS Version 3.0 Technical Reference Manual.}
{	      __RetErUtl returns the status of the last error from DOS, }
{	      not the status of the last function call. 		}
{									}
{	      Use the function __StrErUtl to return descriptive text	}
{	      for any DOS error.					}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc. 1987		}
{_______________________________________________________________________}

function __RetErUtl(var Class,Action,Locus : word) : word;

  var
    Reg : registers;

  begin {__ErrorUtl}

    Class  := 0;		       { Only change these if at DOS	}
    Action := 0;		       { 3.00 or later, and there is an }
    Locus  := 0;		       { error. 			}
    if (_DOSMajorVer < 3) then	       { Pre DOS 3.00, return zero for	}
       __RetErUtl := 0		       { the function value.		}
    else			       { For DOS 3.00 and later, call	}
       with Reg do		       { DOS function $59		}
	 begin
	   AH := $59;
	   BX := 0;
	   Intr(_DOS,Reg);
	   Class      := BH;
	   Action     := BL;
	   Locus      := CH;
	   __RetErUtl := AX
	 end

  end;	{__RetErUtl}
