home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************************
- * errmsg subroutine - Written by Janet Barrett at USGS, Flagstaff
- *
- * subroutine description
- *
- * Display error message in a dialog window
- *
- * argument descriptions
- *
- * argument use
- * -------- ---
- * txtstr Pointer to the first character of the text string that
- * is to be written to the error message dialog window
- *
- * resnum Pointer to an integer which specifies the id number of
- * the dialog window resource that is to be used. This
- * number should not be set to 480 because this number is
- * reserved for the status bar window resource.
- *
- *********************************************************************************/
-
- /********************
- * Standard C includes
- *********************/
- #include <ctype.h>
- #include <stdio.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <string.h>
-
- /***************************
- * Macintosh toolbox includes
- ****************************/
- #include <Packages.h>
-
- void errmsg (char *txtstr,long int *resnum)
- {
- int tsize;
- static DialogPtr nuldp;
- static short xitem,itype;
- static Handle ihandle;
- static Rect irect;
- static char *stxt;
- static char tstr[255];
-
- void FrmDefItem();
-
- /**************************************************************
- * Convert the text string to a format acceptable by the toolbox
- ***************************************************************/
- tsize = strlen(txtstr);
- if (tsize > 255)
- tsize = 255;
- tstr[0] = tsize;
- tstr[1] = 0;
- strcat(tstr,txtstr);
- stxt = tstr;
-
- /*************************************************************
- * Get a pointer to the Dialog window and bring it to the front
- * of all other windows
- **************************************************************/
- nuldp = GetNewDialog(*resnum,NULL,(WindowPtr) -1);
- FrmDefItem(nuldp);
-
- /*****************************************************
- * Get the handle to the text item in the Dialog window
- ******************************************************/
- GetDItem(nuldp,(short) 2,&itype,&ihandle,&irect);
-
- /*******************************************************************
- * Set the text item in the Dialog window to the text string that was
- * sent in the calling routine
- ********************************************************************/
- SetIText(ihandle,stxt);
-
- /*****************************************
- * Wait for the user to click on the OK box
- ******************************************/
- GetDItem(nuldp,(short) 4,&itype,&ihandle,&irect);
-
- while (1) {
- ModalDialog(NULL,&xitem);
- if (xitem == 1)
- break;
- }
-
- /********************************
- * All done with the Dialog window
- *********************************/
- DisposDialog(nuldp);
- }