home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / thesrc15.zip / error.c < prev    next >
C/C++ Source or Header  |  1993-11-17  |  6KB  |  193 lines

  1. /***********************************************************************/
  2. /* ERROR.C - Function to display error messages.                       */
  3. /***********************************************************************/
  4. /*
  5.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  6.  * Copyright (C) 1991-1993 Mark Hessling
  7.  *
  8.  * This program is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU General Public License as
  10.  * published by the Free Software Foundation; either version 2 of
  11.  * the License, or any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16.  * General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to:
  20.  *
  21.  *    The Free Software Foundation, Inc.
  22.  *    675 Mass Ave,
  23.  *    Cambridge, MA 02139 USA.
  24.  *
  25.  *
  26.  * If you make modifications to this software that you feel increases
  27.  * it usefulness for the rest of the community, please email the
  28.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  29.  * This software is going to be maintained and enhanced as deemed
  30.  * necessary by the community.
  31.  *
  32.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  33.  * 36 David Road                     Phone: +61 7 849 7731
  34.  * Holland Park                      Fax:   +61 7 875 5314
  35.  * QLD 4121
  36.  * Australia
  37.  */
  38.  
  39. /*
  40. $Header: C:\THE\RCS\error.c 1.4 1993/09/01 16:26:19 MH Interim MH $
  41. */
  42.  
  43. #include <stdio.h>
  44.  
  45. #include "the.h"
  46. #include "proto.h"
  47.  
  48. /*-------------------------- global   data ----------------------------*/
  49.  
  50. char last_message[160]="";  /* contents of last error message */
  51.  
  52. /*-------------------------- external data ----------------------------*/
  53. extern VIEW_DETAILS *vd_current,*vd_first;
  54. extern char current_file;                   /* pointer to current file */
  55. extern WINDOW *foot,*error_window;
  56. extern bool error_on_screen;
  57. extern char in_profile;    /* indicates if processing profile */
  58. /***********************************************************************/
  59. #ifdef PROTO
  60. void display_error(unsigned short err_num,char *mess)
  61. #else
  62. void display_error(err_num,mess)
  63. unsigned short err_num;
  64. char *mess;
  65. #endif
  66. /***********************************************************************/
  67. {
  68. /*------------------------- external data -----------------------------*/
  69.  extern bool extended_display_mode;
  70.  extern bool BEEPx;
  71.  extern char number_of_files;
  72. /*--------------------------- local data ------------------------------*/
  73.  
  74. static char *error_message[] =
  75. {
  76.  "",
  77.  "Error 0001: Invalid operand:",
  78.  "Error 0002: Too many operands",
  79.  "Error 0003: Too few operands",
  80.  "Error 0004: Invalid number:",
  81.  "Error 0005: Numeric operand too small",
  82.  "Error 0006: Numeric operand too large",
  83.  "Error 0007: Length of operand > 10",
  84.  "Error 0008: Invalid or protected file",
  85.  "Error 0009: File not found",
  86.  "Error 0010: Path not found",
  87.  "Error 0011: File not found in THE_MACRO_PATH:",
  88.  "Error 0012: Margins settings are inconsistant",
  89.  "Error 0013: Invalid key name:",
  90.  "Error 0014: ",
  91.  "Error 0015: ",
  92.  "Error 0016: ",
  93.  "Error 0017: Target not found",
  94.  "Error 0018: Invalid line name",
  95.  "Error 0019: ",
  96.  "Error 0020: ",
  97.  "Error 0021: Invalid command:",
  98.  "Error 0022: File has been changed - use QQUIT to really quit",
  99.  "Error 0023: Help file not found:",
  100.  "Error 0024: Invalid profile command:",
  101.  "Error 0025: Error accessing REXX variable",
  102.  "Error 0026: ",
  103.  "Error 0027: ",
  104.  "Error 0028: ",
  105.  "Error 0029: Cannot edit -",
  106.  "Error 0030: Memory shortage",
  107.  "Error 0031: File already exists - use FFILE/SSAVE",
  108.  "Error 0032: Invalid hexadecimal or decimal value",
  109.  "Error 0033: ",
  110.  "Error 0034: ",
  111.  "Error 0035: ",
  112.  "Error 0036: No lines changed",
  113.  "Error 0037: Operand too long:",
  114.  "Error 0038: Improper cursor position",
  115.  "Error 0039: No remembered operand available",
  116.  "Error 0040: /bin/sh cannot suspend this process",
  117.  "Error 0041: Invalid SOS command:",
  118.  "Error 0042: Invalid SET command:",
  119.  "Error 0043: ",
  120.  "Error 0044: No marked block",
  121.  "Error 0045: Marked block not in current file",
  122.  "Error 0046: ",
  123.  "Error 0047: Operation invalid for line blocks",
  124.  "Error 0048: Operation invalid for box blocks",
  125.  "Error 0049: ",
  126.  "Error 0050: Invalid move location",
  127.  "Error 0051: ",
  128.  "Error 0052: ",
  129.  "Error 0053: Valid only when issued from a REXX macro",
  130.  "Error 0054: REXX interpreter returned an error",
  131.  "Error 0055: No lines sorted",
  132.  "Error 0056: ",
  133.  "Error 0057: Disk full error",
  134.  "Error 0058: ",
  135.  "Error 0059: ",
  136.  "Error 0060: Line name not found:",
  137.  "Error 0061: Colour support not available:",
  138.  "Error 0062: ",
  139.  "Error 0063: ",
  140.  "Error 0064: ",
  141.  "Error 0065: ",
  142.  "Error 0066: Invalid match position",
  143.  "Error 0067: Invalid match character",
  144.  "Error 0068: Matching character not found",
  145.  "Error 0069: Invalid character"
  146. };
  147. unsigned short error_location;
  148. /*--------------------------- processing ------------------------------*/
  149. #ifdef TRACE
  150.  trace_function("error.c:   display_error");
  151. #endif
  152.  sprintf(last_message,"%s %s",error_message[err_num],mess);
  153.  if (in_profile)
  154.    {
  155.     if (!error_on_screen)
  156.       {
  157.        if (number_of_files == 0)
  158.           fprintf(stderr,"*** Messages from profile file  ***\n");
  159.        else
  160.           fprintf(stderr,"*** Messages from profile file for %s%s ***\n",
  161.                          CURRENT_FILE->fpath,CURRENT_FILE->fname);
  162.       }
  163.     error_on_screen = TRUE;
  164.     fprintf(stderr,"%s\n",last_message);
  165. #ifdef TRACE
  166.     trace_return();
  167. #endif
  168.     return;
  169.    }
  170. /*---------------------------------------------------------------------*/
  171. /* If msgmode is off, don't display any errors.                        */
  172. /*---------------------------------------------------------------------*/
  173.  if (!CURRENT_VIEW->message_mode)
  174.     return;
  175.  
  176.  error_on_screen = TRUE;
  177.  wmove(error_window,0,0);
  178.  my_wclrtoeol(error_window);
  179.  if (extended_display_mode)
  180.     mvwaddstr(error_window,0,0,last_message);
  181.  else
  182.     put_string(error_window,0,0,last_message,strlen(last_message));
  183. #if !defined(BSD)
  184.  if (BEEPx)
  185.     beep();
  186. #endif
  187.  wnoutrefresh(error_window);
  188. #ifdef TRACE
  189.  trace_return();
  190. #endif
  191.  return;
  192. }
  193.