Chk function

<< Click to Display Table of Contents >>

Navigation:  Application development > Introduction to BDE programming > BDE Programming in Borland C/C++ >

Chk function

Previous pageReturn to chapter overviewNext page

The Chk function is useful for returning more complete error information about BDE functions than would be returned by the standard error string. Here is the complete code for the Chk function:

 

DBIResult Chk(DBIResult ErrorValue)

{

   char        dbi_status[DBIMAXMSGLEN * 5] = {'\0'};

   DBIMSG      dbi_string = {'\0'};

   DBIErrInfo  ErrInfo;

 

   if (ErrorValue != DBIERR_NONE)

   {

      DbiGetErrorInfo(TRUE, &ErrInfo);

 

      if (ErrInfo.iError == ErrorValue)

      {

         wsprintf(dbi_status, "  ERROR %s", ErrInfo.szErrCode);

 

         if (strcmp(ErrInfo.szContext1, ""))

            wsprintf(dbi_status, "%s\r\n    %s", dbi_status, ErrInfo.szContext1);

         if (strcmp(ErrInfo.szContext2, ""))

            wsprintf(dbi_status, "%s\r\n    %s", dbi_status, ErrInfo.szContext2);

         if (strcmp(ErrInfo.szContext3, ""))

            wsprintf(dbi_status, "%s\r\n    %s", dbi_status, ErrInfo.szContext3);

         if (strcmp(ErrInfo.szContext4, ""))

            wsprintf(dbi_status, "%s\r\n    %s", dbi_status, ErrInfo.szContext4);

      }

      else

      {

         DbiGetErrorString(ErrorValue, dbi_string);

         wsprintf(dbi_status, "  ERROR %s", dbi_string);

      }

      MessageBox(NULL, dbi_status, "BDE Error", MB_OK | MB_ICONEXCLAMATION);

   }

   return ErrorValue;

}