home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!wupost!uwm.edu!rutgers!njitgw.njit.edu!tesla.njit.edu!erh0362
- From: erh0362@tesla.njit.edu (Elliotte Rusty Harold)
- Newsgroups: comp.sys.mac.programmer
- Subject: Parameter Types for GetIndString, ParamText, NewString, et al.
- Message-ID: <1992Jul25.002622.1@tesla.njit.edu>
- Date: 25 Jul 92 05:26:22 GMT
- Sender: news@njit.edu
- Organization: New Jersey Institute of Technology
- Lines: 51
- Nntp-Posting-Host: tesla
-
-
- Can anyone spot the problem in the following code? It typically crashes
- at either the GetIndString, the ParamText, or the StopAlert call. I suspect
- I'm not passing the proper type of argument to one of the toolbox calls (e.g.
- sending a Str255 where I should be passing a StringPtr or vice versa) but I've
- tried this with many different combinations of variable
- type without success. The various
- sample source I've looked at has been inconsistent on the type of argument
- passed to these toolbox calls, i.e. some pass strings and some pass StringPtr's.
- Do I need to allocate space for errorString (a Str255) or is it automatically
- allocated since errorString is really an array of 256 chars? If I
- do need to allocate space, how? Can I dispense with the StringHandle
- errorStringH entirely and just use errorString and &errorString as necessary?
- All suggestions appreciated. Problem function follows.
-
-
- /* returns FAILURE if there is a problem, SUCCESS otherwise */
- Boolean IOCheck(OSErr errornumber) {
-
- Str255 errorString;
- StringHandle errorStringH;
-
- if (errornumber != noErr) {
-
- errorStringH = NewString(&errorString);
- HLock(errorStringH);
- GetIndString(**errorStringH, IO_ERROR_STRINGS,
- -1 * errornumber - ZEROTH_IO_ERROR );
- if ( errorString == NIL_POINTER) {
- ParamText( HOPELESSLY_FATAL_ERROR, NIL_STRING,
- NIL_STRING,NIL_STRING);
- } /* end if */
- else {
- ParamText( *errorStringH, NIL_STRING, NIL_STRING,NIL_STRING) ;
- }
- HUnlock(errorStringH);
- DisposHandle(errorStringH);
- StopAlert(ERROR_ALERT_ID, NIL_POINTER);
-
- return FAILURE;
- } /* end if */
-
- else
- return SUCCESS;
-
-
- } /* end IOCheck */
-
- Elliotte Rusty Harold Department of Applied Mathematics
- elharo@m.njit.edu New Jersey Institute of Technology
- erh0362@tesla.njit.edu Newark, NJ 07103
-