home *** CD-ROM | disk | FTP | other *** search
- /*
- * Routine to look up the system error message corresponding to a
- * result code
- */
- static Str255 eText;
- #define ERRSTR 999 /* Resource id of errlist STR# */
-
- #include <MacTypes.h>
- #include <MacProto.h>
- #include <C_Config.h>
- StringPtr syserrlist (OSErr);
-
-
-
- /*
- *=========================================================================
- * syserrlist (n) - look up text for result code n
- * returns a pointer to a static Str255 containing the text
- *=========================================================================
- */
- StringPtr
- syserrlist (n)
- OSErr n;
- {
- Integer i, j;
- Longint l;
- int len;
-
- for (i = 1;;i++)
- {
- /*
- * The ERRSTR STR# resource should contain strings of the form:
- * "-nnn:Error text"
- * We search through all the STR#'s looking for one with a
- * nnn which matches the error we're looking for.
- */
- eText[0] = 0;
- GetIndString (eText, ERRSTR, i);
- len = eText[0];
- if (len == 0)
- break; /* end of STR# or couldn't get rsrc */
- for (j = 2; j < 6; j++)
- if (eText[j] == ':' || eText[j] == ' ')
- break;
- eText[0] = j - 1; /* shorten string for StringToNum */
- StringToNum (eText, &l);
- eText[0] = len;
- if (l == n)
- break;
- }
- /*
- * We either found the message, or we didn't
- * In the latter case, we just return the number as text
- */
- if (eText[0] == 0)
- NumToString ((long) n, eText);
- return eText;
- }