Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Mac Programming question

Posted on 1997-06-20
3
Medium Priority
?
253 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

Independent Software Vendors: 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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

618 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