home *** CD-ROM | disk | FTP | other *** search
/ Packard Bell - Internet on a CD / internet on a cd.cdr / Internet / sites / Clementine_NASA / clemdsrc.hqx / errmsg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-24  |  2.7 KB  |  93 lines

  1. /********************************************************************************
  2. * errmsg subroutine - Written by Janet Barrett at USGS, Flagstaff
  3. *
  4. * subroutine description
  5. *
  6. *    Display error message in a dialog window
  7. *
  8. * argument descriptions
  9. *
  10. *    argument    use
  11. *    --------    ---
  12. *    txtstr        Pointer to the first character of the text string that
  13. *            is to be written to the error message dialog window
  14. *
  15. *    resnum        Pointer to an integer which specifies the id number of
  16. *            the dialog window resource that is to be used.  This
  17. *            number should not be set to 480 because this number is
  18. *            reserved for the status bar window resource.
  19. *
  20. *********************************************************************************/
  21.  
  22. /********************
  23. * Standard C includes 
  24. *********************/
  25. #include <ctype.h>
  26. #include <stdio.h>
  27. #include <errno.h>
  28. #include <fcntl.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31.  
  32. /***************************
  33. * Macintosh toolbox includes 
  34. ****************************/
  35. #include <Packages.h>
  36.  
  37. void errmsg (char *txtstr,long int *resnum)
  38. {
  39.   int  tsize;
  40.   static DialogPtr  nuldp;
  41.   static short  xitem,itype;
  42.   static Handle  ihandle;
  43.   static Rect  irect;
  44.   static char  *stxt;
  45.   static char  tstr[255];
  46.   
  47.   void FrmDefItem();
  48.  
  49. /**************************************************************
  50. * Convert the text string to a format acceptable by the toolbox
  51. ***************************************************************/
  52.   tsize = strlen(txtstr);
  53.   if (tsize > 255) 
  54.     tsize = 255;
  55.   tstr[0] = tsize;
  56.   tstr[1] = 0;
  57.   strcat(tstr,txtstr);
  58.   stxt = tstr;
  59.   
  60. /*************************************************************
  61. * Get a pointer to the Dialog window and bring it to the front
  62. * of all other windows 
  63. **************************************************************/
  64.   nuldp = GetNewDialog(*resnum,NULL,(WindowPtr) -1);
  65.   FrmDefItem(nuldp);
  66.  
  67. /*****************************************************
  68. * Get the handle to the text item in the Dialog window 
  69. ******************************************************/
  70.   GetDItem(nuldp,(short) 2,&itype,&ihandle,&irect);
  71.  
  72. /******************************************************************* 
  73. * Set the text item in the Dialog window to the text string that was
  74. * sent in the calling routine 
  75. ********************************************************************/        
  76.   SetIText(ihandle,stxt);
  77.     
  78. /*****************************************
  79. * Wait for the user to click on the OK box 
  80. ******************************************/
  81.   GetDItem(nuldp,(short) 4,&itype,&ihandle,&irect);
  82.     
  83.   while (1) {
  84.     ModalDialog(NULL,&xitem);
  85.     if (xitem == 1)
  86.       break;
  87.   }
  88.     
  89. /********************************
  90. * All done with the Dialog window 
  91. *********************************/
  92.   DisposDialog(nuldp);
  93. }