r307: additions for plotfile
[ctsim.git] / libctgraphics / ezset.cpp
index b850f56c2f17db0eec2bb58363b2de009442bcc4..ed396aad6efd9f460712a166798482d9be6f6f69 100644 (file)
@@ -1,8 +1,12 @@
 /*****************************************************************************
+**  FILE IDENTIFICATION
+**
+**      EZSET - Parameter control for EZPLOT           
+**
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ezset.cpp,v 1.1 2000/06/19 18:05:03 kevin Exp $
+**  $Id: ezset.cpp,v 1.10 2000/12/20 14:39:09 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
 **  along with this program; if not, write to the Free Software
 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ******************************************************************************/
-/*----------------------------------------------------------------------*/
-/*                     EZSET - Parameter control for EZPLOT            */
-/*                                                                     */
-/*----------------------------------------------------------------------*/
 
+#include "ctsupport.h"
 #include "ezplot.h"
 #include "pol.h"
-#include "cio.h"
-
-static int ezcmd (char *comm);
-static int do_cmd(int lx);
-static void do_data(void);
-static void do_help(void);
-static void bad_option(char *opt);
-static void initkw(void);
 
-static int modeinteract = FALSE;
-static int curveinteract = -1;
-static int ezset_firstcall = TRUE;
-static int eztrace = TRUE;
-
-int 
-ezset (char *command)
+bool EZPlot::ezset_initialized = false;
+\r
+\r
+bool\r
+EZPlot::ezset (const std::string& command)\r
+{\r
+       return ezset (command.c_str());\r
+}\r
+
+bool 
+EZPlot::ezset (const char const *command)
 {
-    if (ezplot_firstcall == TRUE) {
-       ezinit ();
-    }
-    if (ezset_firstcall == TRUE) {
-       pol_init();
-       initkw();
-       pol_skpword ("please");
-       pol_skpword ("use");
-       pol_skpword ("are");
-       pol_skpword ("and");
-       pol_skpword ("is");
-       pol_skpword ("the");
-       pol_skpword ("equals");
-       pol_skpchar ("=");
-       ezset_firstcall = FALSE;
-
-       pol_usefile (P_USE_STR,"");
-       set_inputline ("!eoc ,");
-       pol_reader ();
-       pol_closefile ();
-    }
-    return (ezcmd (command));
+       if (! ezset_initialized) {
+               pol_init();
+               initkw();
+               pol_skpword ("please");
+               pol_skpword ("use");
+               pol_skpword ("are");
+               pol_skpword ("and");
+               pol_skpword ("is");
+               pol_skpword ("the");
+               pol_skpword ("equals");
+               pol_skpchar ("=");
+               
+               pol_usefile (P_USE_STR,"");
+               set_inputline ("!eoc ,");
+               pol_reader ();
+               pol_closefile ();
+               ezset_initialized = true;
+       }
+       return ezcmd (command);
 }
 
-static int 
-ezcmd (char *comm)
+bool 
+EZPlot::ezcmd (const char const *comm)
 {
-       char str[MAXTOK+1];
-       int code, retval;
-
-       retval = TRUE;
        pol_usefile (P_USE_STR, "");
        set_inputline (comm);
-
-       if (pol_usertok (str, &code) == FALSE) {
-           fputs("Illegal EZSET command\n", stderr);
-           pol_reader();
-           retval = FALSE;
-           goto ezexit;
-       }
-
-       if (code != S_INTERACTIVE) {
-           retval = do_cmd (code);
-       } else {
-           modeinteract = TRUE;
-           pol_reader();
-           do {
-               fputs ("Enter EZSET command, DATA, EXIT, or HELP\n>", stderr);
-               if (get_inputline (stdin) != TRUE)
-                   goto ezexit;
-               while (pol_lookchar() != EOF) {
-                   if (pol_usertok (str, &code) == FALSE) {
-                       if (pol_lookchar() != EOF) {
-                           fputs ("illegal EZSET command\n", stderr);
-                           pol_reader();
-                       }
-                   } else if (code == S_DATA) {
-                       pol_reader ();
-                       do_data ();
-                   } else if (code == S_HELP) {
-                       pol_reader();
-                       do_help ();
-                   } else if (code == S_EXIT) {
-                       pol_reader();
-                       goto ezexit;
-                   } else
-                       do_cmd (code);
-               }
-               putc (NEWLINE, stderr);
-           } while (TRUE);
-           modeinteract = FALSE;
-           curveinteract = -1;
+       
+       char str[MAXTOK+1];
+       int code;
+       bool retval = true;
+       if (! pol_usertok (str, &code)) {
+               sys_error(ERR_WARNING, "Illegal EZSET command: %s", str);
+               pol_reader();
+               retval = false;
        }
-ezexit:
+       else
+               retval = do_cmd (code);
+       
        pol_closefile();                        /* close input string file */
        return (retval);
 }
 
 
-static int 
-do_cmd (int lx)
+bool
+EZPlot::do_cmd (int lx)
 {
-       char str [MAXTOK+1];
+       char str [1024];
+       char strIn [1024];
        int n;
        double f;
-
+       
        switch (lx) {
-           case S_CRT:
-               if (pol_word("no", 2) == TRUE)
-                   ez.d_usecrt = FALSE;
-               else {
-                   ez.d_usecrt = TRUE;
+       case S_TEXTSIZE:
+               if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
+               {
+                       if (f >= 0.0 && f <= 1.0) {
+                               v_textsize = f;
+                               s_textsize = TRUE;
+                       } else
+                               s_textsize = FALSE;
                }
                break;
-           case S_EPSON:
-               if (pol_word("no", 2) == TRUE)
-                   ez.d_useprt = FALSE;
-               else
-                   ez.d_useprt = TRUE;
+       case S_REPLOT:
+               plot ();
                break;
-           case S_TEXTSIZE:
-               if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
-                 {
-                   if (f >= 0.0 && f <= 1.0) {
-                       ez.v_textsize = f;
-                       ez.s_textsize = TRUE;
-                   } else
-                       ez.s_textsize = FALSE;
-                 }
-               break;
-           case S_PRTMODE:
-               if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
-                 {
-                   if (n >= 0 && n <= 6)
-                       ez.d_prtmode = n;
-                   else
-                       ez.d_prtmode = PRTMODE_DEF;
-                 }
-               break;
-           case S_XBUF:
-               if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
-                 {
-                   if (n > 2 && n <= 960)
-                       ez.d_xprtbuf = n;
-                   else
-                       ez.d_xprtbuf = XBUF_DEF;
-                 }
-               break;
-           case S_YBUF:
-               if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
-                 {
-                   if (n > 2 && n <= 960)
-                       ez.d_yprtbuf = n;
-                   else
-                       ez.d_yprtbuf = YBUF_DEF;
-                 }
-               break;
-           case S_REPLOT:
-               ez.i_plotimmediate = TRUE;
-               ezplot (NULL, NULL, 0);
-#if 0
-               if (modeinteract == TRUE)
-                   WAITKEY();
-#endif
-               ez.i_plotimmediate = FALSE;
-               break;
-           case S_CLEAR:
-               ezclear ();
-               break;
-           case S_TITLE:
-               gettext (ez.c_title, MAXTITLE);
-               break;
-           case S_LEGEND:
-               gettext (ez.c_legend, MAXLEGEND);
-               if (modeinteract == TRUE && curveinteract >= 0)
-                   strncpy (ez.curve[curveinteract].legend, ez.c_legend, MAXLEGEND);
-               break;
-           case S_XLABEL:
-               gettext (ez.c_xlabel, MAXLABEL);
-               break;
-           case S_YLABEL:
-               gettext (ez.c_ylabel, MAXLABEL);
-               break;
-           case S_XCROSS:
+       case S_CLEAR:
+               clearCurves ();
+               break;
+       case S_TITLE:
+               gettext (strIn, sizeof(strIn));
+               c_title = strIn;
+               break;
+       case S_LEGEND:
+               gettext (strIn, sizeof(strIn));
+               c_legend = strIn;
+               break;
+       case S_XLABEL:
+               gettext (strIn, sizeof(strIn));
+               c_xlabel = strIn;
+               break;
+       case S_YLABEL:
+               gettext (strIn, sizeof(strIn));
+               c_ylabel = strIn;
+               break;
+       case S_XCROSS:
                if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
-                   ez.v_xcross = f;
-                   ez.s_xcross = TRUE;
+                       v_xcross = f;
+                       s_xcross = TRUE;
                } else
-                   ez.s_xcross = FALSE;
+                       s_xcross = FALSE;
                break;
-           case S_YCROSS:
+       case S_YCROSS:
                if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
-                   ez.v_ycross = f;
-                   ez.s_ycross = TRUE;
+                       v_ycross = f;
+                       s_ycross = TRUE;
                } else
-                   ez.s_ycross = FALSE;
+                       s_ycross = FALSE;
                break;
-           case S_NOXAXIS:
-               ez.o_xaxis = NOAXIS;
+       case S_NOXAXIS:
+               o_xaxis = NOAXIS;
                break;
-           case S_NOYAXIS:
-               ez.o_yaxis = NOAXIS;
+       case S_NOYAXIS:
+               o_yaxis = NOAXIS;
                break;
-           case S_XLIN:
-               ez.o_xaxis = LINEAR;
+       case S_XLIN:
+               o_xaxis = LINEAR;
                break;
-           case S_YLIN:
-               ez.o_yaxis = LINEAR;
+       case S_YLIN:
+               o_yaxis = LINEAR;
                break;
-           case S_XLOG:
-               ez.o_xaxis = LOG;
+       case S_XLOG:
+               o_xaxis = LOG;
                break;
-           case S_YLOG:
-               ez.o_yaxis = LOG;
+       case S_YLOG:
+               o_yaxis = LOG;
                break;
-           case S_XAUTOSCALE:
-               ez.s_xmin = FALSE;
-               ez.s_xmax = FALSE;
+       case S_XAUTOSCALE:
+               s_xmin = FALSE;
+               s_xmax = FALSE;
                break;
-           case S_YAUTOSCALE:
-               ez.s_ymin = FALSE;
-               ez.s_ymax = FALSE;
+       case S_YAUTOSCALE:
+               s_ymin = FALSE;
+               s_ymax = FALSE;
                break;
-           case S_XMIN:
+       case S_XMIN:
                if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
-                   ez.v_xmin = f;
-                   ez.s_xmin = TRUE;
+                       v_xmin = f;
+                       s_xmin = TRUE;
                }
                break;
-           case S_XMAX:
+       case S_XMAX:
                if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
-                   ez.v_xmax = f;
-                   ez.s_xmax = TRUE;
+                       v_xmax = f;
+                       s_xmax = TRUE;
                }
                break;
-           case S_YMIN:
+       case S_YMIN:
                if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
-                   ez.v_ymin = f;
-                   ez.s_ymin = TRUE;
+                       v_ymin = f;
+                       s_ymin = TRUE;
                }
                break;
-           case S_YMAX:
+       case S_YMAX:
                if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
-                   ez.v_ymax = f;
-                   ez.s_ymax = TRUE;
+                       v_ymax = f;
+                       s_ymax = TRUE;
                }
                break;
-           case S_SOLID:
-               ez.o_linestyle = LS_SOLID;
-               if (modeinteract == TRUE && curveinteract >= 0)
-                   ez.curve[curveinteract].linestyle = LS_SOLID;
+       case S_SOLID:
+               o_linestyle = SGP::LS_SOLID;
                break;
-           case S_DASH:
+       case S_DASH:
                if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
-                   if (n == 1)
-                       ez.o_linestyle = LS_DASH1;
-                   else if (n == 2)
-                       ez.o_linestyle = LS_DASH2;
-                   else if (n == 3)
-                       ez.o_linestyle = LS_DASH3;
-                   else if (n == 4)
-                       ez.o_linestyle = LS_DASH4;
-                   else
-                       ez.o_linestyle = LS_DASH1;
+                       if (n == 1)
+                               o_linestyle = SGP::LS_DASH1;
+                       else if (n == 2)
+                               o_linestyle = SGP::LS_DASH2;
+                       else if (n == 3)
+                               o_linestyle = SGP::LS_DASH3;
+                       else if (n == 4)
+                               o_linestyle = SGP::LS_DASH4;
+                       else
+                               o_linestyle = SGP::LS_DASH1;
                } else
-                   ez.o_linestyle = LS_DASH1;
-               if (modeinteract == TRUE && curveinteract >= 0)
-                   ez.curve[curveinteract].linestyle = ez.o_linestyle;
+                       o_linestyle = SGP::LS_DASH1;
                break;
-           case S_NOLINE:
-               ez.o_linestyle = LS_NOLINE;
-               if (modeinteract == TRUE && curveinteract >= 0)
-                   ez.curve[curveinteract].linestyle = LS_NOLINE;
+       case S_NOLINE:
+               o_linestyle = SGP::LS_NOLINE;
                break;
-           case S_PEN:
-           case S_COLOR:
+       case S_PEN:
+       case S_COLOR:
                if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
-                 {
-                   if (n >= 0 && n <= MAXCOLOR)
-                       ez.o_color = n;
-                   else
-                       bad_option("The color you picked");
-                 }
-               if (modeinteract == TRUE && curveinteract >= 0)
-                   ez.curve[curveinteract].color = ez.o_color;
+               {
+                       if (n >= 0)
+                               o_color = n;
+                       else
+                               bad_option("The color you picked");
+               }
                break;
-           case S_BOX:
-               ez.o_box = TRUE;
+       case S_BOX:
+               o_box = TRUE;
                break;
-           case S_NOBOX:
-               ez.o_box = FALSE;
+       case S_NOBOX:
+               o_box = FALSE;
                break;
-           case S_GRID:
-               ez.o_grid = TRUE;
+       case S_GRID:
+               o_grid = TRUE;
                break;
-           case S_NOGRID:
-               ez.o_grid = FALSE;
+       case S_NOGRID:
+               o_grid = FALSE;
                break;
-           case S_XLENGTH:
+       case S_XLENGTH:
                if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
-                   if (f > 0.0 && f <= 1.0)
-                       ez.o_xlength = f;
-               break;
-           case S_YLENGTH:
+                       if (f > 0.0 && f <= 1.0)
+                               o_xlength = f;
+                       break;
+       case S_YLENGTH:
                if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
-                   if (f > 0.0 && f <= 1.0)
-                       ez.o_ylength = f;
-               break;
-           case S_XPORIGIN:
+                       if (f > 0.0 && f <= 1.0)
+                               o_ylength = f;
+                       break;
+       case S_XPORIGIN:
                if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
-                   if (f >= 0.0 && f < 1.0)
-                       ez.o_xporigin = f;
-               break;
-           case S_YPORIGIN:
+                       if (f >= 0.0 && f < 1.0)
+                               o_xporigin = f;
+                       break;
+       case S_YPORIGIN:
                if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
-                   if (f >= 0.0 && f < 1.0)
-                       ez.o_yporigin = f;
-               break;
-           case S_TAG:
+                       if (f >= 0.0 && f < 1.0)
+                               o_yporigin = f;
+                       break;
+       case S_TAG:
                if (pol_word("no", 2) == TRUE)
-                   ez.o_tag = FALSE;
+                       o_tag = FALSE;
                else if (pol_word("off", 2) == TRUE)
-                   ez.o_tag = FALSE;
+                       o_tag = FALSE;
                else
-                   ez.o_tag = TRUE;
+                       o_tag = TRUE;
                break;
-           case S_LEGENDBOX:
+       case S_LEGENDBOX:
                if (pol_word("inside", 2) == TRUE)
-                   ez.o_legendbox = INSIDE;
+                       o_legendbox = INSIDE;
                else if (pol_word("outside", 3) == TRUE)
-                   ez.o_legendbox = OUTSIDE;
+                       o_legendbox = OUTSIDE;
                else if (pol_word("none",2) == TRUE)
-                   ez.o_legendbox = NOLEGEND;
+                       o_legendbox = NOLEGEND;
                else {
-                   gettext (str, MAXTOK);
-                   bad_option(str);
+                       gettext (str, MAXTOK);
+                       bad_option(str);
                }
                break;
-           case S_XLEGEND:
+       case S_XLEGEND:
                if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
-                 {
-                   if (f >= 0.0 && f < 1.0) {
-                       ez.v_xlegend = f;
-                       ez.s_xlegend = TRUE;
-                   }
-                   else
-                     ez.s_xlegend = FALSE;
-                 }
-               break;
-           case S_YLEGEND:
+               {
+                       if (f >= 0.0 && f < 1.0) {
+                               v_xlegend = f;
+                               s_xlegend = TRUE;
+                       }
+                       else
+                               s_xlegend = FALSE;
+               }
+               break;
+       case S_YLEGEND:
                if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
-                 {
-                   if (f >= 0.0 && f < 1.0) {
-                       ez.v_ylegend = f;
-                       ez.s_ylegend = TRUE;
-                   }
-                   else
-                     ez.s_ylegend = FALSE;
-                 }
-               break;
-           case S_CURVES:
-               if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
-                   if (n < 1)
-                       n = 1;
-                   else if (n > MAXCURVES)
-                       n = MAXCURVES;
-                   if (modeinteract == TRUE) {
-                       curveinteract = n - 1;
-                       if (ez.o_unknowncurves == FALSE && ez.o_reqcurves < n)
-                            ez.o_reqcurves = n;
-                   } else {
-                       ezfree ();
-                       ez.o_reqcurves = n;
-                   }
-               } else {
-                   if (pol_word ("unknown", 7) == TRUE)
-                       ez.o_unknowncurves = TRUE;
-                   else if (pol_word ("end", 3) == TRUE) {
-                       ez.o_unknowncurves = FALSE;
-                       ez.o_reqcurves = ez.i_numcurves;
-                       ez.i_plotimmediate = TRUE;
-                       ezplot (NULL, NULL, 0);
-                       ez.i_plotimmediate = FALSE;
-                   }
+               {
+                       if (f >= 0.0 && f < 1.0) {
+                               v_ylegend = f;
+                               s_ylegend = TRUE;
+                       }
+                       else
+                               s_ylegend = FALSE;
                }
                break;
-           case S_SYMBOL:
+       case S_SYMBOL:
                if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
-                   if (n > 0 && n <= MAXSYMBOL)
-                       ez.o_symbol = n;
-                   else
-                       ez.o_symbol = 1;
-                   if (modeinteract == TRUE && curveinteract >= 0)
-                       ez.curve[curveinteract].symbol = ez.o_symbol;
+                       if (n > 0 && n <= MAXSYMBOL)
+                               o_symbol = n;
+                       else
+                               o_symbol = 1;
                } else {
-                   if (pol_word("every",5) == TRUE) {
-                       if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
-                           if (n > 0)
-                               ez.o_symfreq = n;
-                           else
-                               ez.o_symfreq = 1;
-                           if (modeinteract == TRUE && curveinteract >= 0)
-                               ez.curve[curveinteract].symfreq = ez.o_symfreq;
+                       if (pol_word("every",5) == TRUE) {
+                               if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
+                                       if (n > 0)
+                                               o_symfreq = n;
+                                       else
+                                               o_symfreq = 1;
+                               }
+                       } else if (pol_word ("none",4) == TRUE) {
+                               o_symbol = -1;
                        }
-                   } else if (pol_word ("none",4) == TRUE) {
-                       ez.o_symbol = -1;
-                       if (modeinteract == TRUE && curveinteract >= 0)
-                           ez.curve[curveinteract].symbol = ez.o_symbol;
-                   }
                }
                break;
-           case S_XTICKS:
+       case S_XTICKS:
                if (pol_usertok(str,&lx) == FALSE)
-                   break;
+                       break;
                if (lx == S_ABOVE)
-                   ez.o_xticks = ABOVE;
+                       o_xticks = ABOVE;
                else if (lx == S_BELOW)
-                   ez.o_xticks = BELOW;
+                       o_xticks = BELOW;
                else if (lx == S_NOLABEL)
-                   ez.o_xtlabel = FALSE;
+                       o_xtlabel = FALSE;
                else if (lx == S_LABEL)
-                   ez.o_xtlabel = TRUE;
+                       o_xtlabel = TRUE;
                else if (lx == S_MAJOR) {
-                    if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
-                       if (n > 1 && n < 100)
-                           ez.o_xmajortick = n;
+                       if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
+                               if (n > 1 && n < 100)
+                                       o_xmajortick = n;
                } else if (lx == S_MINOR)
-                    if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
-                       if (n >= 0 && n < 100)
-                           ez.o_xminortick = n;
-               break;
-           case S_YTICKS:
+                       if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
+                               if (n >= 0 && n < 100)
+                                       o_xminortick = n;
+                               break;
+       case S_YTICKS:
                if (pol_usertok(str,&lx) == FALSE)
-                   break;
+                       break;
                if (lx == S_RIGHT)
-                   ez.o_yticks = RIGHT;
+                       o_yticks = RIGHT;
                else if (lx == S_LEFT)
-                   ez.o_yticks = LEFT;
+                       o_yticks = LEFT;
                else if (lx == S_NOLABEL)
-                   ez.o_ytlabel = FALSE;
+                       o_ytlabel = FALSE;
                else if (lx == S_LABEL)
-                   ez.o_ytlabel = TRUE;
+                       o_ytlabel = TRUE;
                else if (lx == S_MAJOR) {
-                    if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
-                       if (n > 1 && n < 100)
-                           ez.o_ymajortick = n;
+                       if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
+                               if (n > 1 && n < 100)
+                                       o_ymajortick = n;
                } else if (lx == S_MINOR)
-            if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
-                       if (n >= 0 && n < 100)
-                           ez.o_yminortick = n;
-               break;
-           case S_LXFRAC:
+                       if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
+                               if (n >= 0 && n < 100)
+                                       o_yminortick = n;
+                               break;
+       case S_LXFRAC:
                if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
-                   if (n >= 0) {
-                       ez.v_lxfrac = n;
-                       ez.s_lxfrac = TRUE;
-                   }
+                       if (n >= 0) {
+                               v_lxfrac = n;
+                               s_lxfrac = TRUE;
+                       }
                } else
-                   ez.s_lxfrac = FALSE;
+                       s_lxfrac = FALSE;
                break;
-           case S_LYFRAC:
+       case S_LYFRAC:
                if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
-                   if (n >= 0) {
-                       ez.v_lyfrac = n;
-                       ez.s_lyfrac = TRUE;
-                   }
+                       if (n >= 0) {
+                               v_lyfrac = n;
+                               s_lyfrac = TRUE;
+                       }
                } else
-                   ez.s_lyfrac = FALSE;
-               break;
-           case S_USTART:
-               if (pol_word("no", 2) == TRUE)
-                   ez.o_ustart = FALSE;
-               else
-                   ez.o_ustart = TRUE;
+                       s_lyfrac = FALSE;
                break;
-           case S_UFINISH:
-               if (pol_word("no", 2) == TRUE)
-                   ez.o_ufinish = FALSE;
-               else
-                   ez.o_ufinish = TRUE;
                break;
-           default:
+       default:
                fprintf (stderr, "Unimplemented EZPLOT command\n");
                break;
-       }
-
-       pol_reader ();
-       return (TRUE);
+  }
+  
+  pol_reader ();
+  return (true);
 }
 
-static void do_data (void)
-{
-       double x[MAXPTS], y[MAXPTS], d;
-       int c, i;
-
-       printf ("Enter your data in free format\n");
-       printf ("Alternate X and Y coordinates\n");
-       printf ("Type ^Z (control Z) to terminate data entry\n");
 
-       pol_usefile (P_USE_FILE, "");
-       for (i = 0; i < MAXPTS; i++) {
-           if (pol_float (&d, TT_REAL, FALSE, 0, 0) == TRUE)
-               x[i] = d;
-           else
-               break;
-           if (pol_float (&d, TT_REAL, FALSE, 0, 0) == TRUE)
-               y[i] = d;
-           else
-               break;
-       }
 
-       if ((c = pol_inchar()) != EOF) {
-           ungetc (c, stdin);
-           printf("Error reading in points, read char %d, plotting %d points\n", c, i);
-       }
-       if (i > 0)
-           ezplot (x, y, i);
-       pol_closefile ();
-}
-
-
-static void do_help (void )
-{
-       fputs ("EZSET Help: not available\n", stderr);
-}
-
-
-static void 
-bad_option (char *opt)
+void 
+EZPlot::bad_option (char *opt)
 {
-       fprintf(stderr,"%s is an INVALID option (sorry!)\n", opt);
+       sys_error (ERR_WARNING, "INVALID option: %s", opt);
 }
 
 /*----------------------------------------------------------------------*/
@@ -562,105 +394,90 @@ static struct key {
        char *keyword;
        int code;
 } keytab[] = {
-       "solid",        S_SOLID,
-       "dash",         S_DASH,
-       "noline",       S_NOLINE,
-       "black",        S_BLACK,
-       "red",          S_RED,
-       "blue",         S_BLUE,
-       "green",        S_GREEN,
-       "pen",          S_PEN,
-       "symbol",       S_SYMBOL,
-/*     "every",        S_EVERY,        */
-/*     "none",         S_NONE,         */
-
-       "curves",       S_CURVES,
-       "curve",        S_CURVES,
-/*     "unknown",      S_UNKNOWN,      */
-/*     "end",          S_END,          */
-
-       "legend",       S_LEGEND,
-       "xlegend",      S_XLEGEND,
-       "ylegend",      S_YLEGEND,
-
-       "xlin",         S_XLIN,
-       "ylin",         S_YLIN,
-       "xlog",         S_XLOG,
-       "ylog",         S_YLOG,
-       "xlabel",       S_XLABEL,
-       "ylabel",       S_YLABEL,
-       "xlength",      S_XLENGTH,
-       "ylength",      S_YLENGTH,
-
-       "xticks",       S_XTICKS,
-       "yticks",       S_YTICKS,
-       "above",        S_ABOVE,
-       "label",        S_LABEL,
-       "below",        S_BELOW,
-       "nolabel",      S_NOLABEL,
-       "right",        S_RIGHT,
-       "left",         S_LEFT,
-
-       "xautoscale",   S_XAUTOSCALE,
-       "yautoscale",   S_YAUTOSCALE,
-       "xmin",         S_XMIN,
-       "ymin",         S_YMIN,
-       "xmax",         S_XMAX,
-       "ymax",         S_YMAX,
-       "lxfrac",       S_LXFRAC,
-       "lyfrac",       S_LYFRAC,
-       "xcross",       S_XCROSS,
-       "ycross",       S_YCROSS,
-       "noxaxis",      S_NOXAXIS,
-       "noyaxis",      S_NOYAXIS,
-       "xporigin",     S_XPORIGIN,
-       "yporigin",     S_YPORIGIN,
-       "title",        S_TITLE,
-       "xtitle",       S_XTITLE,
-       "ytitle",       S_YTITLE,
-
-       "replot",       S_REPLOT,
-       "clear",        S_CLEAR,
-       "store",        S_STORE,
-       "restore",      S_RESTORE,
-       "ustart",       S_USTART,
-       "ufinish",      S_UFINISH,
-       "amark",        S_AMARK,
-       "interactive",  S_INTERACTIVE,
-       "units",        S_UNITS,
-       "inches",       S_INCHES,
-       "user",         S_USER,
-
-       "data",         S_DATA,
-       "help",         S_HELP,
-       "exit",         S_EXIT,
-
-       "box",          S_BOX,
-       "nobox",        S_NOBOX,
-       "grid",         S_GRID,
-       "nogrid",       S_NOGRID,
-       "major",        S_MAJOR,
-       "minor",        S_MINOR,
-       "color",        S_COLOR,
-       "legendbox",    S_LEGENDBOX,
-
-       "epson",        S_EPSON,
-       "crt",          S_CRT,
-       "no",           S_NO,
-
-       "textsize",     S_TEXTSIZE,
-       "xbuf",         S_XBUF,
-       "ybuf",         S_YBUF,
-       "prtmode",      S_PRTMODE,
+    {"solid",  S_SOLID},
+       {"dash", S_DASH},
+       {"noline",      S_NOLINE},
+       {"black",       S_BLACK},
+       {"red",         S_RED},
+       {"blue",                S_BLUE},
+       {"green",       S_GREEN},
+                               {"pen",         S_PEN},
+       {"symbol",      S_SYMBOL},
+       {"every",       S_EVERY},    
+       {"none",                S_NONE},  
+       {"legend",      S_LEGEND},
+       {"xlegend",     S_XLEGEND},
+       {"ylegend",     S_YLEGEND},
+       
+       {"xlin",                S_XLIN},
+                               {"ylin",                S_YLIN},
+       {"xlog",                S_XLOG},
+       {"ylog",                S_YLOG},
+       {"xlabel",      S_XLABEL},
+       {"ylabel",      S_YLABEL},
+       {"xlength",     S_XLENGTH},
+       {"ylength",     S_YLENGTH},
+       
+       {"xticks",      S_XTICKS},
+       {"yticks",      S_YTICKS},
+       {"above",       S_ABOVE},
+       {"label",       S_LABEL},
+       {"below",       S_BELOW},
+       {"nolabel",     S_NOLABEL},
+       {"right",       S_RIGHT},
+       {"left",                S_LEFT},
+       
+       {"xautoscale",  S_XAUTOSCALE},
+       {"yautoscale",  S_YAUTOSCALE},
+       {"xmin",                S_XMIN},
+       {"ymin",                S_YMIN},
+       {"xmax",                S_XMAX},
+       {"ymax",                S_YMAX},
+       {"lxfrac",      S_LXFRAC},
+       {"lyfrac",      S_LYFRAC},
+       {"xcross",      S_XCROSS},
+       {"ycross",      S_YCROSS},
+       {"noxaxis",     S_NOXAXIS},
+       {"noyaxis",     S_NOYAXIS},
+       {"xporigin",    S_XPORIGIN},
+       {"yporigin",    S_YPORIGIN},
+       {"title",       S_TITLE},
+       {"xtitle",      S_XTITLE},
+       {"ytitle",      S_YTITLE},
+       
+       {"replot",      S_REPLOT},
+       {"clear",       S_CLEAR},
+       {"store",       S_STORE},
+       {"restore",     S_RESTORE},
+       {"amark",       S_AMARK},
+       {"units",       S_UNITS},
+       {"inches",      S_INCHES},
+       {"user",                S_USER},
+       
+       {"data",                S_DATA},
+       {"help",                S_HELP},
+       {"exit",                S_EXIT},
+       
+       {"box",         S_BOX},
+       {"nobox",       S_NOBOX},
+       {"grid",                S_GRID},
+       {"nogrid",      S_NOGRID},
+       {"major",       S_MAJOR},
+       {"minor",       S_MINOR},
+       {"color",       S_COLOR},
+       {"legendbox",   S_LEGENDBOX},
+       
+       {"no",          S_NO},
+       
+       {"textsize",    S_TEXTSIZE},
 };
 
-#define NKEYS  (sizeof(keytab) / sizeof(struct key))
+static const unsigned int NKEYS=(sizeof(keytab) / sizeof(struct key));
 
-static void initkw(void)
+void 
+EZPlot::initkw(void)
 {
-       int i;
-
-       for (i = 0; i < NKEYS; i++)
-           if (pol_install(keytab[i].keyword, keytab[i].code) == FALSE)
-               sys_error(ERR_SEVERE, "error installing ezset keywords [initkw]");
+       for (unsigned int i = 0; i < NKEYS; i++)
+               if (! pol_install(keytab[i].keyword, keytab[i].code))
+                       sys_error(ERR_SEVERE, "error installing ezset keywords [initkw]");
 }