home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Utilities / Programming / Snippets 2.4 / Snippets / Snippets.rsrc / TEXT_414_14.txt < prev    next >
Encoding:
Text File  |  1996-01-21  |  2.9 KB  |  129 lines

  1. /**********************************************************************
  2.  
  3.     FnError.cp
  4.  
  5. ***********************************************************************/
  6.  
  7. /*
  8.     Provides a very simple error dialog in the center of the screen.
  9.     You have the option of immediately quitting application after user
  10.     clicks OK.
  11.     
  12.     Functions Include:
  13.     
  14.       FnErr_DisplayStrID      Display error using string ID
  15.       FnErr_DisplayStr        Display error string
  16. */
  17.  
  18. /********** Available Error ID's */
  19. const short kGeneralError =    900;
  20. const short kBadSystem =       901;
  21. const short kNoResource =      902;
  22. const short kAppleEventError = 903;
  23.  
  24. /********** Constants */
  25. const short kErrorAlert = 900;
  26. #define kNilPtr     0L
  27. #define kNilStr     "\p"
  28. #define kFatalError "\pFatal Error!"
  29.  
  30. /********** Prototypes */
  31. void FnErr_DisplayStrID( int    stringNum,
  32.                          int    quitFlag );
  33. void FnErr_DisplayStr(   Str255 s1,
  34.                          Str255 s2,
  35.                          Str255 s3,
  36.                          Str255 s4,
  37.                          int    quitFlag );
  38.  
  39. /********** DisplayStrID */
  40.  
  41. void FnErr_DisplayStrID( int stringNum, int quitFlag )
  42. {
  43.     StringHandle   errorStringH;
  44.     
  45.     if ( ( errorStringH = GetString( stringNum ) ) == kNilPtr )
  46.         ParamText( kFatalError, kNilStr, kNilStr, kNilStr );
  47.     else
  48.     {
  49.         HLock( (Handle)errorStringH );
  50.         ParamText( *errorStringH, kNilStr, kNilStr, kNilStr );
  51.         HUnlock( (Handle)errorStringH );
  52.     }
  53.     StopAlert( kErrorAlert, kNilPtr );
  54.     if( quitFlag )
  55.         ExitToShell();
  56. }
  57.  
  58. /********** DisplayStr */
  59.  
  60. void FnErr_DisplayStr(   Str255 s1,
  61.                          Str255 s2,
  62.                          Str255 s3,
  63.                          Str255 s4,
  64.                          int    quitFlag )
  65. {
  66.     ParamText( s1, s2, s3, s4 );
  67.     StopAlert( kErrorAlert, kNilPtr );
  68.     if( quitFlag )
  69.         ExitToShell();
  70. }
  71.  
  72.  
  73. /**********************************************************************
  74.  
  75.     FnError.r
  76.  
  77. ***********************************************************************/
  78.  
  79. #include <Types.r>
  80.  
  81. resource 'DITL' (900, "Error Alert") {
  82.     {    /* array DITLarray: 2 elements */
  83.         /* [1] */
  84.         {59, 288, 79, 348},
  85.         Button {
  86.             enabled,
  87.             "OK"
  88.         },
  89.         /* [2] */
  90.         {10, 75, 54, 343},
  91.         StaticText {
  92.             enabled,
  93.             "^0^1^2^3"
  94.         }
  95.     }
  96. };
  97.  
  98. resource 'ALRT' (900, "Error Alert") {
  99.     {94, 80, 183, 438},
  100.     900,
  101.     {    /* array: 4 elements */
  102.         /* [1] */
  103.         OK, visible, sound1,
  104.         /* [2] */
  105.         OK, visible, sound1,
  106.         /* [3] */
  107.         OK, visible, sound1,
  108.         /* [4] */
  109.         OK, visible, sound1,
  110.     },
  111. };
  112.  
  113. resource 'STR ' (900, "General Error") {
  114.     "Sorry, but a fatal error just occured!"
  115. };
  116.  
  117. resource 'STR ' (901, "System Error") {
  118.     "Sorry, you must have System 7 or later to run this application."
  119. };
  120.  
  121. resource 'STR ' (902, "Resource Error") {
  122.     "Error: Resource could not be loaded."
  123. };
  124.  
  125. resource 'STR ' (903, "Can't Handle AppleEvent Error") {
  126.     "Error: Could not handle AppleEvent."
  127. };
  128.  
  129. // End of File