home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / PInterfaces / ErrMgr.p < prev    next >
Encoding:
Text File  |  1994-07-27  |  3.7 KB  |  107 lines  |  [TEXT/MPS ]

  1. {
  2.     File:        ErrMgr.p
  3.  
  4.     Copyright:    © 1987-88, 1993-94 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Version:    3.4a3
  8.     Created:    Tuesday, March 30, 1993 18:00
  9.  
  10. }
  11.  
  12. {$IFC UNDEFINED UsingIncludes}
  13. {$SETC UsingIncludes := 0}
  14. {$ENDC}
  15.  
  16. {$IFC NOT UsingIncludes}
  17.     UNIT ErrMgr;
  18.     INTERFACE
  19. {$ENDC}
  20.  
  21. {$IFC UNDEFINED UsingErrMgr AND UNDEFINED __ERRMGR__}
  22. {$SETC UsingErrMgr := 1}
  23. {$SETC __ERRMGR__ := 1}
  24.  
  25. {$I+}
  26. {$SETC ErrMgrIncludes := UsingIncludes}
  27. {$SETC UsingIncludes := 1}
  28. {$IFC UNDEFINED UsingTypes AND UNDEFINED __TYPES__}
  29. {$I Types.p}
  30. {$ENDC}
  31. {$SETC UsingIncludes := ErrMgrIncludes}
  32.  
  33.  
  34. PROCEDURE InitErrMgr(toolErrFilename: Str255;sysErrFilename: Str255;showToolErrNbrs: BOOLEAN);
  35.  
  36. { ErrMgr initialization.This must be done before using any other ErrMgr
  37. routine.  Set showToolErrNbrs to true if you want all tool messages to contain
  38. the error number following the message text enclosed in parentheses (e.g.,
  39. "<msg txt> ([OS] Error <n>)"; system error messages always contain the error
  40. number).  The toolErrFileName parameter is used to specify the name of a
  41. tool-specific error file, and should be the NULL or a null string if not used
  42. (or if the tool's data fork is to be used as the error file, see
  43. GetToolErrText for futher details). The sysErrFileName parameter is used to
  44. specify the name of a system error file, and should normally be the NULL or a
  45. null string, which causes the ErrMgr to look in the MPW Shell directory for
  46. "SysErrs.Err" (see GetSysErrText). }
  47.  
  48.  
  49. PROCEDURE CloseErrMgr; C;
  50.  
  51. { Ideally a CloseErrMgr should be done at the end of execution to make sure all
  52. files opened by the ErrMgr are closed.    You can let normal program termination
  53. do the closing.  But if you are a purist...
  54.  }
  55.  
  56.  
  57. PROCEDURE GetSysErrText(msgNbr: INTEGER;errMsg: StringPtr);
  58.  
  59. (* Get the error message text corresponding to system error number errNbr from
  60. the system error message file (whose name was specified in the InitErrMgr
  61. call).    The text of the message is returned in errMsg and the function returns
  62. a pointer to errMsg.  The maximum length of the message is limited to 254
  63. characters.
  64.  
  65. Note, if a system message filename was not specified to InitErrMgr, then the
  66. ErrMgr assumes the message file contained in the file "SysErrs.Err".  This
  67. file is first accessed as "                                 {ShellDirectory}SysErrs.Err" on the assumption that
  68. SysErrs.Err is kept in the same directory as the MPW Shell.  If the file
  69. cannot be opened, then an open is attempted on "SysErrs.Err" in the System
  70. Folder. *)
  71.  
  72.  
  73. PROCEDURE AddErrInsert(insert: Str255;msgString: StringPtr); C;
  74.  
  75. { Add another insert to an error message string.This call is used when more
  76. than one insert is to be added to a message (because it contains more than
  77. one '^' character).
  78.  }
  79.  
  80.  
  81. PROCEDURE GetToolErrText(msgNbr: INTEGER;errInsert: Str255;errMsg: StringPtr);
  82.  
  83. (* Get the error message text corresponding to tool error number errNbr from
  84. the tool error message file (whose name was specified in the InitErrMgr
  85. call).    The text of the message is returned in errMsg and the function returns
  86. a pointer to errMsg.  The maximum length of the message is limited to 254
  87. characters.  If the message is to have an insert, then ErrInsert should be a
  88. pointer to it.    Otherwise it should be either be a null string or a NULL
  89. pointer.
  90.  
  91. Inserts are indicated in error messages by specifying a '^' to indicate where
  92. the insert is to be placed.
  93.  
  94. Note, if a tool message filename was not specified to InitErrMgr, then the
  95. ErrMgr assumes the message file contained in the data fork of the tool calling
  96. the ErrMgr.  This name is contained in the Shell variable    {Command} and the
  97. value of that variable is used to open the error message file. *)
  98.  
  99.  
  100.  
  101. {$ENDC}    { UsingErrMgr }
  102.  
  103. {$IFC NOT UsingIncludes}
  104.     END.
  105. {$ENDC}
  106.  
  107.