title: Error Handling in C
body: <p>Hello there and thank you for stopping by.</p>
  
  <p><strong>The solution has been found by making use of proprietary code. See bottom for used code.
  Thanks everybody for input and help!</strong></p>
  
  <p>I'm fairly new to C programming (meaning I coded some very basic stuff). At the moment, I'm writing a script in C language. I've tried searching the site, but no examples seem applicable to my case, or simply do not work.
  What it does is basically opening a file (or a batch of multiple files), telling the master program to plot a graph of selected string (the open_curve() is a program specific function).</p>
  
  <p>Now my problem is that one of the strings (lets say string2 in the code below) is not always present. When it's missing, the script produces an error and quits. How to stop this happening? VBA has an option many people loathe, but I regard it to be quite useful in this situation: On Error resume next. I know it might be missing and it is not of importance in this case. When it's there I need it. When it's not, too bad... so if no errors pop up and the value is missing, that is perfectly fine.
  Question is, how can I get a similar functionality in C?</p>
  
  <pre><code>#define NMAX 10 // max. Anzahl Dateien
  string n[NMAX]; // Global wegen Stack!
  
  void main(void)
  {
  string *q;
  int i,nmax=NMAX;
  nmax=GetOpenFileName(n, nmax, "Daten-Dateien (*.DAT)", "*.DAT");
  
  
  
      for (i=0, q=n; i&lt;nmax; i++,q++)
      {
  
  
              ql.open_file(.file=*q);
              close_curve();
              open_curve(.name="\"String1\"");
              open_curve(.name="\"String2\"");
              open_curve(.name="\"String3\"");
  
  
              printf("File %2d: %s\n",i,*q);
  
      }   
  getch();
  }
  </code></pre>
  
  <p>The prototype:</p>
  
  <pre><code>int [ql.]open_curve(.name = string[, .no = int,
  
                       .color = int, .lthick = int,
  
                       .linetype = int,
  
                       .marker = int, .drawall = int,
  
                       .markersize = float,
  
                       .bars = int, .ynull = float,
  
                       .ymin = float, .ymax = float,
  
                       .xmin = float, .xmax = float,
  
                       .yaxis = int,  .xaxis = int,
  
                       .axis = int,  .colsrc = int,
  
                       .xsignal = string, .csignal = string,
  
                       .index = string, 
  
                       .xfrom = float, .xuntil = float,
  
                       .usemarker = int]);
  </code></pre>
  
  <p>The Code, with my problem solved:
  Now returns empty when not found.</p>
  
  <pre><code>for (i=0, q=n; i&lt;nmax; i++,q++)
          {
  
  
                  ql.open_file(.file=*q);
                  close_curve();
                  open_curve(.name="\"String1\"");
  Warninglevel = 2;
              Errorlevel3 = 3; // Fehler nicht melden, weitermachen
                  err = open_curve(.name="\"String2\"");
              Errorlevel3 = 0;
              Warninglevel = 0;               
                  open_curve(.name="\"String3\"");
  
  
                  printf("File %2d: %s\n",i,*q);
  
          }   
      getch();
      }
  </code></pre>
  
  <p>with the warning and error levels explained as following:</p>
  
  <pre><code>extern int Warninglevel  - Warnings will...
  
                              0 - Produce an Error box
                              1 - be ignored
                              2 - be ignored
  
   extern int Errorlevel1   - Errors will...
  
                         0 - Produce an Error box (popup) and cancel script
                         1 - Produce an Error box and continue script                       2 - ignored and cancel script.
  </code></pre>