Solved

Mac Programming question

Posted on 1997-06-20
3
207 Views
Last Modified: 2013-12-26
I saw a code sample some time ago that I believe used a STR# resource built into the system to translate sn OSErr error code into an english message. Does anyonw know the resource ID or of any other built-in way to do this. I want to avoid creating a masssive case statement that I have to maintain.
0
Comment
Question by:creality
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
Paul B earned 0 total points
ID: 1291517
Yes you can get the error text built in :)
It is tricky though.

There is a file in your development environment called SysErrs.err.
For Codewarior it is in Metrowerks:Metrowerks Codewarior:SysErrs.err.

COPY this file to the same folder as your application.
I am not sure if it works with aliases.

In your project file you need to link with either PPCToolLibs.o for PPC or NuToolLibs.o for 68K

In your source code:
#include <string.h>
#include <stdio.h>

#include <ErrMgr.h>               // Error manager include
#include <Errors.h>

void main(void)
{
    char errorstring[256];        // buffer for error text
    OSErr err;                    // error number
 
    printf("Error test\n");
    pascalStrings = true;         // pascal string for errors
                                  // init the error manager
                                  // first param is path to tool error file
                                  // second is pacth to sys error file
                                  // since the file is in the same folder
                                  // we pass null
                                  // last param to incluyde error number in text
    InitErrMgr(NULL, NULL, true);


      err = notEnoughHardwareErr;   // some error number
                                    // get the error text
      GetSysErrText(err, errorstring);
                                  
      p2cstr((StringPtr)errorstring);// convert pascal to C string
                                     // display error
      printf("%d %s\n", err, errorstring);

}

You may want to look at <ErrMgr.h> for more detail
Good Luck
Paul Baxter
pbaxter@assistivetech.com
0
 

Author Comment

by:creality
ID: 1291518
Paul answer was great. He even provided some source code as a sample, going beyond what I would have expected.



Thanks Paul.
0
 
LVL 3

Expert Comment

by:rickyr
ID: 1291519
Hi.
It is good to see that some are here to help others, rather than for the points.
a perfect example to set for other forums.

All credit to you creality.


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Process filename extension 3 209
Window placement 17 95
NotAlone Challenge 20 88
building a service to accessed via telnet client, want colors ? 4 98
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question