//******************************************************************* // File: corpserr.cpp // Author: Jeff Ruby // Agency: U.S. Army Topographic Engineering Center // Last Modified: 11/1/94 // // This is the source file that is used to display error // messages from corpscon.cpp. It is // currently set up to display error messages in windows, but // it can be modified to send the error messages any where. // Constants for error numbers are included in cverror.h. //******************************************************************* #include #include #include #include "corpserr.h" #include "corpskey.h" #include "corpsgui.h" //******************************************************************* // This procedure will get the correct error message and send // it to ShowError(). Error codes are defined in cverror.h. //******************************************************************* int CheckError(int input,char *opt) { char message[200]; strcpy(message,""); if(opt[strlen(opt)-1] == '\n') opt[strlen(opt)-1] = '\0'; switch(input) { case NO_ERROR: return 0; case COORD_OUT_OF_RANGE: sprintf(message,"Coordinate: %s Out of CONUS limits.",opt); break; case ERROR_DATABASE: sprintf(message,"Database error."); break; case ERROR_DIR_OPEN: sprintf(message,"Error opening vcbin.dir."); break; case ERROR_DIR_READ: sprintf(message,"Error reading vcbin.dir."); break; case ERROR_COF_OPEN: sprintf(message,"Error opening vcbin.cof."); break; case ERROR_COF_READ: sprintf(message,"Error reading vcbin.cof."); break; case INVALID_LAT_ENTERED: sprintf(message,"Invalid latitude entered: %s N",opt); break; case INVALID_LON_ENTERED: sprintf(message,"Invalid longitude entered: %s W",opt); break; case INVALID_NORTHING_ENTERED: sprintf(message,"Invalid northing entered: %s",opt); break; case INVALID_EASTING_ENTERED: sprintf(message,"Invalid easting entered: %s",opt); break; case INVALID_HEIGHT_ENTERED: sprintf(message,"Invalid height entered: %s",opt); break; case INVALID_LAT_VALUE: sprintf(message,"Invalid latitude value: %s N",opt); break; case INVALID_LON_VALUE: sprintf(message,"Invalid longitude value: %s W",opt); break; case INVALID_UTMZONE_ENTERED: sprintf(message,"Invalid UTM zone entered(1-16): %s",opt); break; case FILE_NOT_FOUND: sprintf(message,"File %s not found.",opt); break; case UNABLE_TO_OPEN_FOR_WRITING: sprintf(message,"Unable to open %s for writing.",opt); break; default: break; } ShowError(message); return 1; } //******************************************************************* // This procedure will display an error message. It is // currently set up to display messages to an error window, // but it can be modified to send the messages to other output // devices. ShowError() currently uses window.cpp to create // the error window. //******************************************************************* int ShowError(char *str) { int x1=8,y1=16,x2=72,y2=20,ret=0; char before[1000]; windowbox tmp; default_windowbox(&tmp); SetDimensions(&tmp,x1,y1,x2,y2); SetColors(&tmp,RED,YELLOW,YELLOW,WHITE,WHITE); tmp.bordertoggle = ON; tmp.shadow = ON; strcpy(tmp.title," ERROR! "); gettext(x1,y1,x2+2,y2+1,&before); MakeWindow(&tmp); WriteText(3,2,&tmp,str); WriteText(3,4,&tmp,"Hit any key to continue.\a"); ret = GetKey(); puttext(x1,y1,x2+2,y2+1,&before); return ret; }