Index: /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/CheckPipe.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/CheckPipe.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/CheckPipe.c	(revision 13409)
@@ -12,4 +12,7 @@
 }
 
+// after we have processed the command, we unblock the socket
+# define FINISHED(A) { fcntl (sock, F_SETFL, O_NONBLOCK); return (A); }
+
 int CheckPipe () {
 
@@ -21,5 +24,5 @@
     sock = KapaServerWait (InitSocket, &Address);
     if (sock == -1) return (TRUE);
-    close (InitSocket); /* stop listening on this socket */
+    close (InitSocket); /* stop listening for new connections */
     fcntl (sock, F_SETFL, O_NONBLOCK);  
   }
@@ -47,19 +50,22 @@
   }
   
+  /* once we get a command, we block to ensure we get complete messages */
+  fcntl (sock, F_SETFL, !O_NONBLOCK);  
+
   /***** handle different messages ****/
   if (ACTIVE_CURSOR) {
     if (strcmp (word, "NCUR")) {
       fprintf (stderr, "wrong end message %s\n", word);
-      return (TRUE);
+      FINISHED (TRUE);
     }
     ACTIVE_CURSOR = FALSE;
-    return (TRUE);
+    FINISHED (TRUE);
   } 
 
-  if (!strcmp (word, "QUIT")) return (FALSE);
+  if (!strcmp (word, "QUIT")) FINISHED (FALSE);
   
   if (!strcmp (word, "CURS")) {
     ACTIVE_CURSOR = TRUE;
-    return (TRUE);
+    FINISHED (TRUE);
   }
   
@@ -67,5 +73,5 @@
     status = PScommand (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
   
@@ -73,5 +79,5 @@
     status = PNGit (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
   
@@ -79,5 +85,5 @@
     status = PPMit (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
   
@@ -85,11 +91,12 @@
     status = LoadFrame (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
   
   if (!strcmp (word, "PLOT")) {
     status = LoadObject (sock);
-    KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    // LoadObject sends its own handshake
+    // KiiSendCommand (sock, 4, "DONE");
+    FINISHED (status);
   }
   
@@ -97,5 +104,5 @@
     status = LoadLabels (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (TRUE);
+    FINISHED (TRUE);
   }
   
@@ -103,5 +110,5 @@
     status = LoadTextlines (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (TRUE);
+    FINISHED (TRUE);
   }
   
@@ -109,5 +116,5 @@
     status = Resize (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
 
@@ -115,5 +122,5 @@
     GetLimits (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (TRUE);
+    FINISHED (TRUE);
   }
   
@@ -121,5 +128,5 @@
     status = SetLimits (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (TRUE);
+    FINISHED (TRUE);
   }
   
@@ -127,5 +134,5 @@
     status = SetSection (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (TRUE);
+    FINISHED (TRUE);
   }
   
@@ -133,5 +140,5 @@
     status = ListSection (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (TRUE);
+    FINISHED (TRUE);
   }
   
@@ -139,5 +146,5 @@
     status = DefineSection (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (TRUE);
+    FINISHED (TRUE);
   }
   
@@ -145,5 +152,5 @@
     status = MoveSection (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (TRUE);
+    FINISHED (TRUE);
   }
   
@@ -151,5 +158,5 @@
     status = SetFont (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (TRUE);
+    FINISHED (TRUE);
   }
   
@@ -158,5 +165,5 @@
     status = EraseCurrentPlot ();
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
   
@@ -165,5 +172,5 @@
     status = ErasePlots ();
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
   
@@ -172,5 +179,5 @@
     status = EraseSections ();
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
 
@@ -179,5 +186,5 @@
     status = EraseImage ();
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
 
@@ -186,5 +193,5 @@
     status = EraseOverlay (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
 
@@ -192,5 +199,5 @@
     status = LoadPicture (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
 
@@ -198,5 +205,5 @@
     status = LoadOverlay (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
 
@@ -207,5 +214,5 @@
     status = LoadTickmarks (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
   */
@@ -214,5 +221,5 @@
     status = SaveOverlay (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
 
@@ -220,5 +227,5 @@
     status = CSaveOverlay (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
 
@@ -226,5 +233,5 @@
     status = JPEGit24 (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
 
@@ -232,5 +239,5 @@
     status = Center (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (status);
+    FINISHED (status);
   }
 
@@ -238,10 +245,8 @@
     GetPixelCount (sock);
     KiiSendCommand (sock, 4, "DONE");
-    return (TRUE);
+    FINISHED (TRUE);
   }
 
   fprintf (stderr, "unknown signal %s\n", word);
-
-  return (TRUE);
-
+  FINISHED (TRUE);
 }
Index: /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadLabels.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadLabels.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadLabels.c	(revision 13409)
@@ -15,6 +15,4 @@
   graph = section->graph;
   
-  fcntl (sock, F_SETFL, !O_NONBLOCK);  
-  
   KiiScanMessage (sock, "%d", &mode);
   label = KiiRecvData (sock);
@@ -25,6 +23,4 @@
   strncpy (graph[0].label[mode].text, label, Nbytes);
   label[Nbytes] = 0;
-
-  fcntl (sock, F_SETFL, O_NONBLOCK);  
   
   c = GetRotFont (&size);
Index: /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadObject.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadObject.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadObject.c	(revision 13409)
@@ -1,4 +1,5 @@
 # include "Ximage.h"
 # include <errno.h>
+# define DEBUG 1
 
 int LoadObject (int sock) {
@@ -14,6 +15,4 @@
   }
   graph = section->graph;
-  
-  fcntl (sock, F_SETFL, !O_NONBLOCK);  
   
   N = graph[0].Nobjects;
@@ -45,7 +44,12 @@
 		  &graph[0].objects[N].x0, &graph[0].objects[N].x1, 
 		  &graph[0].objects[N].y0, &graph[0].objects[N].y1);
-  
-  fcntl (sock, F_SETFL, O_NONBLOCK);  
-  
+
+  // acknowledge receipt of the metadata
+  KiiSendCommand (sock, 4, "DONE"); 
+  
+  // XXX Currently, I require these in a special order.  The data includes a message defining the
+  // object type.  This could be made more flexible by using the information (though we still need
+  // to know how many items will be sent)
+
   if (!LoadVectorData (sock, graph, N, "x")) {
     FreeObjectData (&graph[0].objects[N]);
@@ -100,13 +104,26 @@
 }
 
-/* load data for the named component */
 int LoadVectorData (int sock, KapaGraphWidget *graph, int N, char *type) {
   
   int Npts, Ninpts, status, Ntry;
   int bytes_left;
-  char *buff;
+  char *buff, type_send[16];
+  int Npts_send, Nbytes_send;
 
   buff = NULL;
   Npts = graph[0].objects[N].Npts;
+
+  KiiWaitAnswer (sock, "PLOB");
+  KiiScanMessage (sock, "%s %d %d", type_send, &Npts_send, &Nbytes_send);
+  if (strcmp (type, type_send)) {
+    fprintf (stderr, "Kapa Communication error: unexpected data type %s vs %s\n", type_send, type);
+  }
+  if (Npts_send != Npts) {
+    fprintf (stderr, "Kapa Communication error: unexpected number of points %d vs %d\n", Npts_send, Npts);
+  }
+  if (Nbytes_send != Npts_send*sizeof(float)) {
+    fprintf (stderr, "Kapa Communication error: unexpected data size %d vs %d\n", Nbytes_send, Npts_send*sizeof(float));
+  }
+
   status = 1;
   if (!strcmp (type, "x")) {
@@ -140,4 +157,6 @@
 
   bytes_left = Npts*sizeof (float);
+
+  fcntl (sock, F_SETFL, O_NONBLOCK);  
 
   Ntry = 0;
@@ -169,4 +188,8 @@
     perror ("kapa load");
   }
+
+  fcntl (sock, F_SETFL, !O_NONBLOCK);  
+  KiiSendCommand (sock, 4, "DONE"); 
+
   if (Ninpts != Npts*sizeof(float)) {  
     fprintf (stderr, "error: expected %d bytes, but got only %d\n", Ninpts, (unsigned int)(Npts*sizeof(float)));
Index: /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadOverlay.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadOverlay.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadOverlay.c	(revision 13409)
@@ -42,5 +42,5 @@
 	fprintf (stderr, "error: pipe closed\n");
 	free (buffer);
-	fcntl (sock, F_SETFL, O_NONBLOCK);  
+	fcntl (sock, F_SETFL, !O_NONBLOCK);  
 	return (FALSE);
       }
@@ -89,5 +89,4 @@
   REALLOCATE (image[0].overlay[N].objects, Object, MAX (1, image[0].overlay[N].Nobjects));
   image[0].overlay[N].active = TRUE;
-  fcntl (sock, F_SETFL, O_NONBLOCK);  
 
   if (USE_XWINDOW) {
Index: /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadPicture.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadPicture.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadPicture.c	(revision 13409)
@@ -20,8 +20,5 @@
   KiiSendMessage (sock, "%d", graphic->Npixels);
 
-  fcntl (sock, F_SETFL, !O_NONBLOCK);  
-
   header.Naxes = 2;
-
   KiiScanMessage (sock, "%d %d %d %d %lf %lf", &header.Naxis[0], &header.Naxis[1]);
   KiiScanMessage (sock, "%d %d %d %d %lf %lf", &header.bitpix, &header.unsign, &header.bzero, &header.bscale);
@@ -55,4 +52,6 @@
   }
 
+  fcntl (sock, F_SETFL, !O_NONBLOCK);  
+
   if (DEBUG) fprintf (stderr, "read %d bytes\n", image[0].matrix.size);
   /* it it not obvious this condition should kill kii, but ... */
Index: /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadTextlines.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadTextlines.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadTextlines.c	(revision 13409)
@@ -16,6 +16,4 @@
   }
 
-  fcntl (sock, F_SETFL, !O_NONBLOCK);  
-  
   graph[0].Ntextline = MAX (graph[0].Ntextline, 0);
   N = graph[0].Ntextline;
@@ -38,6 +36,4 @@
   strcpy (graph[0].textline[N].text, string);
   free (string);
-
-  fcntl (sock, F_SETFL, O_NONBLOCK);  
   
   string = GetRotFont (&size);
Index: /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadTickmarks.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadTickmarks.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/kapa2/src/LoadTickmarks.c	(revision 13409)
@@ -15,6 +15,4 @@
   }
   image   = section->image;
-
-  fcntl (sock, F_SETFL, !O_NONBLOCK);  
 
   Nobjects = image[0].tickmarks.Nobjects;
@@ -65,6 +63,4 @@
 
   if (USE_XWINDOW) Refresh ();
-
-  fcntl (sock, F_SETFL, O_NONBLOCK);  
   return (TRUE);
 }
Index: /branches/kapa-mods-2007-05/Ohana/src/libkapa/include/kapa.h
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/libkapa/include/kapa.h	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/libkapa/include/kapa.h	(revision 13409)
@@ -107,4 +107,5 @@
 int KiiSendData (int device, char *data, int Nbytes);
 char *KiiRecvData (int device);
+int KiiWaitAnswer (int device, char *expect);
 
 /* KiiOpen.c */
@@ -146,5 +147,5 @@
 int KapaInitGraph (Graphdata *graphdata);
 int KapaPrepPlot (int fd, int Npts, Graphdata *graphmode);
-int KapaPlotVector (int fd, int Npts, float *values);
+int KapaPlotVector (int fd, int Npts, float *values, char *type);
 int KapaSetFont (int fd, char *name, int size);
 int KapaSendLabel (int fd, char *string, int mode);
Index: /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/IOfuncs.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/IOfuncs.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/IOfuncs.c	(revision 13409)
@@ -1,3 +1,5 @@
 # include <kapa_internal.h>
+
+/** these function expect to operate with a BLOCKing socket **/
 
 /* why is this not defined in stdarg.h for linux/x64? */
@@ -61,4 +63,5 @@
   status = read (device, buffer, 16);
   buffer[16] = 0;
+  if (status != 16) fprintf (stderr, "dropped message length\n");
 
   /* find the message length, allocate space */
@@ -71,4 +74,6 @@
   message[status] = 0;
   /* make the string easy to parse */
+
+  fprintf (stderr, "message recv: %s\n", message);
 
   /* scan the incoming message */
@@ -116,9 +121,7 @@
 
   ALLOCATE (message, char, length + 1);
-  fcntl (device, F_SETFL, !O_NONBLOCK);  // block until we get the response??
 
   /* read Nbytes from the device */
   status = read (device, message, length);
-  fcntl (device, F_SETFL, O_NONBLOCK);  // unblock
 
   if (status != length) {
@@ -135,2 +138,23 @@
   return (1);
 }
+
+int KiiWaitAnswer (int device, char *expect) {
+
+  int Nbytes;
+  char *answer;
+
+  Nbytes = strlen (expect);
+  ALLOCATE (answer, char, Nbytes + 1);
+
+  KiiScanCommand (device, Nbytes, "%s", answer);
+  if (strcmp (answer, expect)) {
+      fprintf (stderr, "unexpected response %s, expected %s\n", answer, expect); 
+      REALLOCATE (answer, char, 128);
+      Nbytes = read (device, answer, 127);
+      answer[Nbytes] = 0;
+      fprintf (stderr, "extra data in buffer: %d bytes\n", Nbytes);
+      fprintf (stderr, "garbage: %s\n", answer);
+      return (FALSE);
+  }
+  return (TRUE);
+}
Index: /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KapaOpen.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KapaOpen.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KapaOpen.c	(revision 13409)
@@ -75,7 +75,4 @@
   }
   if (!status) return (-1);
-
-  /* this is a blocking wait; use in a separate thread */
-  // fcntl (InitSocket, F_SETFL, !O_NONBLOCK); 
 
   if (DEBUG) fprintf (stderr, "init sock: %d, len: %d\n", InitSocket, length);
@@ -120,5 +117,4 @@
 accepted:
   if (DEBUG) fprintf (stderr, "connection accepted\n");
-  // fcntl (BindSocket, F_SETFL, O_NONBLOCK); 
   return (BindSocket);
 }
@@ -206,5 +202,7 @@
   if (DEBUG) fprintf (stderr, "connected on port: %d\n", Address.sin_port);
   if (DEBUG) fprintf (stderr, "connected\n");
-  fcntl (InitSocket, F_SETFL, O_NONBLOCK); 
+
+  // the client uses a BLOCKing socket by default
+  fcntl (InitSocket, F_SETFL, !O_NONBLOCK); 
   return (InitSocket);
 }
Index: /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KapaWindow.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KapaWindow.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KapaWindow.c	(revision 13409)
@@ -2,14 +2,8 @@
 
 int KiiCenter (int fd, double x, double y, int zoom) {
-
-  char word[5];
 
   KiiSendCommand (fd, 4, "CENT");
   KiiSendMessage (fd, "%8.3f %8.3f %8d ", x, y, zoom);
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   
   return (TRUE);
@@ -17,21 +11,12 @@
 
 int KiiResize (int fd, int Nx, int Ny) {
-
-  char word[5];
 
   KiiSendCommand (fd, 4, "RSIZ");
   KiiSendMessage (fd, "%d %d", Nx, Ny); 
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
-  
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
 
 int KapaBox (int fd, Graphdata *graphdata) {
-
-  char word[5];
 
   KiiSendCommand (fd, 4, "DBOX");
@@ -40,10 +25,5 @@
 
   KiiSendMessage (fd, "%s %s %s", graphdata[0].axis, graphdata[0].labels, graphdata[0].ticks);
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
-  
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
@@ -51,12 +31,6 @@
 int KapaClearCurrentPlot (int fd) {
   
-  char word[5];
-
   KiiSendCommand (fd, 4, "ERSC");
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
@@ -64,12 +38,6 @@
 int KapaClearPlots (int fd) {
   
-  char word[5];
-
   KiiSendCommand (fd, 4, "ERSP");
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
@@ -77,12 +45,6 @@
 int KapaClearSections (int fd) {
   
-  char word[5];
-
   KiiSendCommand (fd, 4, "ERSS");
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
@@ -90,12 +52,6 @@
 int KapaClearImage (int fd) {
   
-  char word[5];
-
   KiiSendCommand (fd, 4, "ERSI");
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
@@ -129,6 +85,4 @@
 int KapaPrepPlot (int fd, int Npts, Graphdata *graphmode) {
 
-  char word[5];
-
   /* tell kapa to look for the incoming image */
   KiiSendCommand (fd, 4, "PLOT"); 
@@ -143,54 +97,48 @@
 		  graphmode[0].xmin, graphmode[0].xmax, 
 		  graphmode[0].ymin, graphmode[0].ymax);
-
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
-  
-  return (TRUE);
-}
-
-int KapaPlotVector (int fd, int Npts, float *values) {
+  KiiWaitAnswer (fd, "DONE");
+  return (TRUE);
+}
+
+int KapaPlotVector (int fd, int Npts, float *values, char *type) {
 
   int Nbytes;
 
   Nbytes = Npts * sizeof (float);
+
+  if (!strcmp(type, "x")) goto valid;
+  if (!strcmp(type, "y")) goto valid;
+  if (!strcmp(type, "z")) goto valid;
+  if (!strcmp(type, "dym")) goto valid;
+  if (!strcmp(type, "dyp")) goto valid;
+  if (!strcmp(type, "dxm")) goto valid;
+  if (!strcmp(type, "dxp")) goto valid;
+  return (FALSE);
+
+valid:
+  KiiSendCommand (fd, 4, "PLOB"); 
+  KiiSendMessage (fd, "%s %d %d", type, Npts, Nbytes); 
+  // XXX send the byte-swap as well...
+
   write (fd, values, Nbytes);
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
 
 int KapaSetFont (int fd, char *name, int size) {
-
-  char word[5];
 
   KiiSendCommand (fd, 4, "FONT");
   KiiSendCommand (fd, 16, "%s", name);
   KiiSendCommand (fd, 16, "%d", size);
-
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
-  
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
 
 int KapaSendLabel (int fd, char *string, int mode) {
-  
-  char word[5];
 
   KiiSendCommand (fd, 4, "LABL");
   KiiSendMessage (fd, "%6d", mode);
   KiiSendData (fd, string, strlen(string));
-
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
-  
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
@@ -198,32 +146,16 @@
 int KapaSendTextline (int fd, char *string, float x, float y, float angle) {
   
-  char word[5];
-
   KiiSendCommand (fd, 4, "PTXT");
   KiiSendMessage (fd, "%f %f %f", x, y, angle);
   KiiSendData (fd, string, strlen(string));
-
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
-  
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
 
 int KapaSetLimits (int fd, Graphdata *graphmode) {
-
-  char word[5];
 
   KiiSendCommand (fd, 4, "SLIM");
   KiiSendMessage (fd, "%g %g %g %g ", graphmode[0].xmin, graphmode[0].xmax, graphmode[0].ymin, graphmode[0].ymax);
-
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
-  
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
@@ -232,21 +164,11 @@
 int KapaGetLimits (int fd, float *dx, float *dy) {
 
-  char word[5];
-
   KiiSendCommand (fd, 4, "LIMS"); 
   KiiScanMessage (fd, "%lf %lf", dx, dy); 
-
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
-  
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
 
 int KapaSetSection (int fd, KapaSection *section) {
-
-  char word[5];
 
   KiiSendCommand (fd, 4, "DSEC");
@@ -257,17 +179,9 @@
 		  section[0].dx,
 		  section[0].dy);
-
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
-  
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
 
 int KapaMoveSection (int fd, char *name, char *direction) {
-
-  char word[5];
 
   if (!strcasecmp(direction, "up")) goto valid;
@@ -282,42 +196,21 @@
   KiiSendCommand (fd, 4, "MSEC");
   KiiSendMessage (fd, "%s %s", name, direction);
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
-  
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
 
 int KapaSelectSection (int fd, char *name) {
-
-  char word[5];
 
   KiiSendCommand (fd, 4, "SSEC");
   KiiSendMessage (fd, "%s", name);
-
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
-  
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
 
 int KapaGetSection (int fd, char *name) {
-
-  char word[5];
 
   KiiSendCommand (fd, 4, "LSEC");
   KiiSendMessage (fd, "%s", name);
-
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
-  
-  return (TRUE);
-}
+  KiiWaitAnswer (fd, "DONE");
+  return (TRUE);
+}
Index: /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiConvert.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiConvert.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiConvert.c	(revision 13409)
@@ -3,15 +3,7 @@
 int KiiJPEG (int fd, const char *filename) {
 
-  char buffer[20], word[5];
-
   KiiSendCommand (fd, 4, "JPEG");
   KiiSendMessage (fd, "%s", filename);
-
-  /* block for the response, which says the operation completed */
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
@@ -19,15 +11,7 @@
 int KapaPNG (int fd, const char *filename) {
 
-  char buffer[20], word[5];
-
   KiiSendCommand (fd, 4, "PNGF");
   KiiSendMessage (fd, "%s", filename);
-
-  /* block for the response, which says the operation completed */
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
@@ -35,15 +19,7 @@
 int KapaPPM (int fd, const char *filename) {
 
-  char buffer[20], word[5];
-
   KiiSendCommand (fd, 4, "PPMF");
   KiiSendMessage (fd, "%s", filename);
-
-  /* block for the response, which says the operation completed */
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
@@ -51,17 +27,7 @@
 int KiiPS (int fd, const char *filename, int scaleMode, int pageMode, char *pagename) {
 
-  char buffer[20], word[5];
-
-  /* the default operation */
   KiiSendCommand (fd, 4, "PSIT");
-
   KiiSendMessage (fd, "%s %s %d %d", filename, pagename, scaleMode, pageMode);
-
-  /* block for the response, which says the operation completed */
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
Index: /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiCursor.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiCursor.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiCursor.c	(revision 13409)
@@ -2,24 +2,14 @@
 
 int KiiCursorOn (int fd) {
-  char word[5];
 
   KiiSendCommand (fd, 4, "CURS");
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
 
 int KiiCursorOff (int fd) {
-  char word[5];
 
   KiiSendCommand (fd, 4, "NCUR");
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
Index: /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiOverlay.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiOverlay.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiOverlay.c	(revision 13409)
@@ -53,5 +53,5 @@
 
   int i, n, Nline;
-  char *buffer, *type, word[5];
+  char *buffer, *type;
 
   KiiSelectOverlay (overname, &n);
@@ -84,13 +84,10 @@
 
   free (buffer);
+  KiiWaitAnswer (fd, "DONE");
 
   /* this is very inefficient: 128 bytes per object vs 17 as binary, plus the
      conversions back and forth
   */
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+
   return (TRUE);
 }
@@ -99,5 +96,4 @@
 
   int n;
-  char word[5];
 
   KiiSelectOverlay (overname, &n);
@@ -105,10 +101,5 @@
   KiiSendCommand (fd, 4, "ERSO");
   KiiSendCommand (fd, 16, "OVERLAY %7d ", n);
-
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
@@ -117,5 +108,4 @@
 
   int n;
-  char word[5];
 
   KiiSelectOverlay (overname, &n);
@@ -128,10 +118,5 @@
 
   KiiSendMessage (fd, "FILE: %d %s", n, file);
-
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
Index: /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiPicture.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiPicture.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiPicture.c	(revision 13409)
@@ -6,5 +6,5 @@
   int Npix, Ncolors, NNcolors, size;
   float *in, min, max;
-  char *out, *outbuffer, *root, word[5];
+  char *out, *outbuffer, *root, extra[1024];
   double a1, a2;
 
@@ -58,9 +58,5 @@
   free (outbuffer);
 
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
@@ -72,5 +68,5 @@
   float *in, min, max;
   char *out, *outbuffer, *root;
-  char buffer[1024], word[5];
+  char buffer[1024];
   double a1, a2;
 
@@ -130,9 +126,5 @@
   free (outbuffer);
 
-  KiiScanCommand (fd, 4, "%s", word);
-  if (strcmp (word, "DONE")) {
-      fprintf (stderr, "unexpected response %s\n", word); 
-      return (FALSE);
-  }
+  KiiWaitAnswer (fd, "DONE");
   return (TRUE);
 }
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/cgrid.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/cgrid.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/cgrid.c	(revision 13409)
@@ -393,6 +393,6 @@
   graphmode.etype = 0;
   PrepPlotting (N, &graphmode);
-  PlotVector (N, Xvec.elements);
-  PlotVector (N, Yvec.elements);
+  PlotVector (N, Xvec.elements, "x");
+  PlotVector (N, Yvec.elements, "y");
 
   free (Xvec.elements);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/cplot.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/cplot.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/cplot.c	(revision 13409)
@@ -68,6 +68,6 @@
   graphmode.etype = 0;
   PrepPlotting (Npts, &graphmode);
-  PlotVector (Npts, Xvec.elements);
-  PlotVector (Npts, Yvec.elements);
+  PlotVector (Npts, Xvec.elements, "x");
+  PlotVector (Npts, Yvec.elements, "y");
   
   free (Xvec.elements);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/czplot.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/czplot.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/czplot.c	(revision 13409)
@@ -61,7 +61,7 @@
   PrepPlotting (Npts, &graphmode);
 
-  PlotVector (Npts, Xvec.elements);
-  PlotVector (Npts, Yvec.elements);
-  PlotVector (Npts, Zvec.elements);
+  PlotVector (Npts, Xvec.elements, "x");
+  PlotVector (Npts, Yvec.elements, "y");
+  PlotVector (Npts, Zvec.elements, "z");
 
   free (Xvec.elements);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/dot.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/dot.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/dot.c	(revision 13409)
@@ -24,6 +24,6 @@
   if (!PrepPlotting (1, &graphmode)) return (FALSE);
   
-  PlotVector (1, &x);
-  PlotVector (1, &y);
+  PlotVector (1, &x, "x");
+  PlotVector (1, &y, "y");
   
   return (TRUE);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/grid.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/grid.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/grid.c	(revision 13409)
@@ -194,6 +194,6 @@
   graphmode.etype = 0;
   PrepPlotting (N, &graphmode);
-  PlotVector (N, Xvec.elements);
-  PlotVector (N, Yvec.elements);
+  PlotVector (N, Xvec.elements, "x");
+  PlotVector (N, Yvec.elements, "y");
 
   free (Xvec.elements);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/line.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/line.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/line.c	(revision 13409)
@@ -25,6 +25,6 @@
   if (!PrepPlotting (2, &graphmode)) return (FALSE);
   
-  PlotVector (2, x);
-  PlotVector (2, y);
+  PlotVector (2, x, "x");
+  PlotVector (2, y, "y");
   
   return (TRUE);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/plot.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/plot.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/plot.c	(revision 13409)
@@ -59,13 +59,13 @@
   if (!PrepPlotting (Npts, &graphmode)) return (FALSE);
   
-  PlotVector (Npts, xvec[0].elements);
-  PlotVector (Npts, yvec[0].elements);
+  PlotVector (Npts, xvec[0].elements, "x");
+  PlotVector (Npts, yvec[0].elements, "y");
   if (graphmode.etype & 0x01) {
-    PlotVector (Npts, dymvec[0].elements);
-    PlotVector (Npts, dypvec[0].elements);
+    PlotVector (Npts, dymvec[0].elements, "dym");
+    PlotVector (Npts, dypvec[0].elements, "dyp");
   }
   if (graphmode.etype & 0x02) {
-    PlotVector (Npts, dxmvec[0].elements);
-    PlotVector (Npts, dxpvec[0].elements);
+    PlotVector (Npts, dxmvec[0].elements, "dxm");
+    PlotVector (Npts, dxpvec[0].elements, "dxp");
   }
   
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/zplot.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/zplot.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/zplot.c	(revision 13409)
@@ -47,7 +47,7 @@
   PrepPlotting (Npts, &graphmode);
 
-  PlotVector (Npts, xvec[0].elements);
-  PlotVector (Npts, yvec[0].elements);
-  PlotVector (Npts, Zvec.elements);
+  PlotVector (Npts, xvec[0].elements, "x");
+  PlotVector (Npts, yvec[0].elements, "y");
+  PlotVector (Npts, Zvec.elements, "z");
 
   free (Zvec.elements);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/catalog.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/catalog.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/catalog.c	(revision 13409)
@@ -391,7 +391,7 @@
     PrepPlotting (N, &graphmode);
     
-    PlotVector (N, Xvec.elements);
-    PlotVector (N, Yvec.elements);
-    PlotVector (N, Zvec.elements);
+    PlotVector (N, Xvec.elements, "x");
+    PlotVector (N, Yvec.elements, "y");
+    PlotVector (N, Zvec.elements, "z");
     
     free (Xvec.elements);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/dmt.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/dmt.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/dmt.c	(revision 13409)
@@ -145,6 +145,6 @@
     PrepPlotting (N, &graphmode);
     
-    PlotVector (N, Xvec.elements);
-    PlotVector (N, Yvec.elements);
+    PlotVector (N, Xvec.elements, "x");
+    PlotVector (N, Yvec.elements, "y");
 
     free (Xvec.elements);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/fitcolors.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/fitcolors.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/fitcolors.c	(revision 13409)
@@ -305,6 +305,6 @@
 	KapaBox (kapa, &graphdata);
 	KapaPrepPlot (kapa, Npts, &graphdata);
-	KapaPlotVector (kapa, Npts, xvec[0].elements);
-	KapaPlotVector (kapa, Npts, yvec[0].elements);
+	KapaPlotVector (kapa, Npts, xvec[0].elements, "x");
+	KapaPlotVector (kapa, Npts, yvec[0].elements, "y");
 
 	for (i = 0; i < 11; i++) {
@@ -314,6 +314,6 @@
 	graphdata.color = KapaColorByName ("red");
 	KapaPrepPlot (kapa, 11, &graphdata);
-	KapaPlotVector (kapa, 11, colorFit);
-	KapaPlotVector (kapa, 11, deltaFit);
+	KapaPlotVector (kapa, 11, colorFit, "x");
+	KapaPlotVector (kapa, 11, deltaFit, "y");
 
 	KapaSetFont (kapa, "helvetica", 8);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/fitsed.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/fitsed.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/fitsed.c	(revision 13409)
@@ -268,6 +268,6 @@
 	graphdata.etype = 0;
 	KapaPrepPlot (kapa, Nfilter, &graphdata);
-	KapaPlotVector (kapa, Nfilter, wavecode);
-	KapaPlotVector (kapa, Nfilter, SEDtable[minFit.row][0].mags);
+	KapaPlotVector (kapa, Nfilter, wavecode, "x");
+	KapaPlotVector (kapa, Nfilter, SEDtable[minFit.row][0].mags, "y");
 	graphdata.color = KapaColorByName ("red");
 	graphdata.etype = 1;
@@ -280,8 +280,8 @@
 	}
 	KapaPrepPlot (kapa, Nfilter, &graphdata);
-	KapaPlotVector (kapa, Nfilter, wavecode);
-	KapaPlotVector (kapa, Nfilter, fitmags);
-	KapaPlotVector (kapa, Nfilter, fiterrs);
-	KapaPlotVector (kapa, Nfilter, fiterrs);
+	KapaPlotVector (kapa, Nfilter, wavecode, "x");
+	KapaPlotVector (kapa, Nfilter, fitmags, "y");
+	KapaPlotVector (kapa, Nfilter, fiterrs, "dym");
+	KapaPlotVector (kapa, Nfilter, fiterrs, "dyp");
 	KapaSendLabel (kapa, "model,fit (mags)", 1);
 
@@ -308,8 +308,8 @@
 	}
 	KapaPrepPlot (kapa, Nfilter, &graphdata);
-	KapaPlotVector (kapa, Nfilter, wavecode);
-	KapaPlotVector (kapa, Nfilter, fitmags);
-	KapaPlotVector (kapa, Nfilter, fiterrs);
-	KapaPlotVector (kapa, Nfilter, fiterrs);
+	KapaPlotVector (kapa, Nfilter, wavecode, "x");
+	KapaPlotVector (kapa, Nfilter, fitmags, "y");
+	KapaPlotVector (kapa, Nfilter, fiterrs, "dym");
+	KapaPlotVector (kapa, Nfilter, fiterrs, "dyp");
 	KapaSendLabel (kapa, "wavelength (nm)", 0);
 	KapaSendLabel (kapa, "resid (mags)", 1);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/images.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/images.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/images.c	(revision 13409)
@@ -283,6 +283,6 @@
     graphmode.etype = 0;
     PrepPlotting (N, &graphmode);
-    PlotVector (N, Xvec.elements);
-    PlotVector (N, Yvec.elements);
+    PlotVector (N, Xvec.elements, "x");
+    PlotVector (N, Yvec.elements, "y");
   }
 
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/imbox.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/imbox.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/imbox.c	(revision 13409)
@@ -77,6 +77,6 @@
       graphmode.etype = 0;
       PrepPlotting (8, &graphmode);
-      PlotVector (8, Xvec.elements);
-      PlotVector (8, Yvec.elements);
+      PlotVector (8, Xvec.elements, "x");
+      PlotVector (8, Yvec.elements, "y");
     }
   skip:
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/imdense.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/imdense.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/imdense.c	(revision 13409)
@@ -63,6 +63,6 @@
     graphmode.etype = 0;
     PrepPlotting (N, &graphmode);
-    PlotVector (N, Xvec.elements);
-    PlotVector (N, Yvec.elements);
+    PlotVector (N, Xvec.elements, "x");
+    PlotVector (N, Yvec.elements, "y");
   }
 
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/imstats.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/imstats.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/imstats.c	(revision 13409)
@@ -55,6 +55,6 @@
   graphmode.etype = 0;
   PrepPlotting (Nimage, &graphmode);
-  PlotVector (Nimage, Xvec.elements);
-  PlotVector (Nimage, Yvec.elements);
+  PlotVector (Nimage, Xvec.elements, "x");
+  PlotVector (Nimage, Yvec.elements, "y");
   
   free (Xvec.elements);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/lcurve.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/lcurve.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/lcurve.c	(revision 13409)
@@ -155,9 +155,9 @@
 
   PrepPlotting (N, &graphmode);
-  PlotVector (N, Xvec.elements);
-  PlotVector (N, Yvec.elements);
+  PlotVector (N, Xvec.elements, "x");
+  PlotVector (N, Yvec.elements, "y");
   if (ErrorBars) {
-    PlotVector (N, dYvec.elements);
-    PlotVector (N, dYvec.elements);
+    PlotVector (N, dYvec.elements, "x");
+    PlotVector (N, dYvec.elements, "y");
   }
 
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/pcat.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/pcat.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/pcat.c	(revision 13409)
@@ -84,6 +84,6 @@
     graphmode.etype = 0;
     PrepPlotting (Npts, &graphmode);
-    PlotVector (Npts, Xvec.elements);
-    PlotVector (Npts, Yvec.elements);
+    PlotVector (Npts, Xvec.elements, "x");
+    PlotVector (Npts, Yvec.elements, "y");
   }
 
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/procks.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/procks.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/procks.c	(revision 13409)
@@ -115,6 +115,6 @@
   PrepPlotting (N, &graphmode);
   
-  PlotVector (N, Xvec.elements);
-  PlotVector (N, Yvec.elements);
+  PlotVector (N, Xvec.elements, "x");
+  PlotVector (N, Yvec.elements, "y");
 
   /* now plot vectors between two extrema */
@@ -148,6 +148,6 @@
   PrepPlotting (N, &graphmode);
   
-  PlotVector (N, Xvec.elements);
-  PlotVector (N, Yvec.elements);
+  PlotVector (N, Xvec.elements, "x");
+  PlotVector (N, Yvec.elements, "y");
 
   free (Xvec.elements);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/showtile.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/showtile.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/showtile.c	(revision 13409)
@@ -87,6 +87,6 @@
     graphmode.etype = 0;
     PrepPlotting (N, &graphmode);
-    PlotVector (N, Xvec.elements);
-    PlotVector (N, Yvec.elements);
+    PlotVector (N, Xvec.elements, "x");
+    PlotVector (N, Yvec.elements, "y");
   }
 
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/simage.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/simage.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/simage.c	(revision 13409)
@@ -156,7 +156,7 @@
   PrepPlotting (Npts, &graphmode);
 
-  PlotVector (Npts, Xvec.elements);
-  PlotVector (Npts, Yvec.elements);
-  PlotVector (Npts, Zvec.elements);
+  PlotVector (Npts, Xvec.elements, "x");
+  PlotVector (Npts, Yvec.elements, "y");
+  PlotVector (Npts, Zvec.elements, "z");
 
   free (Xvec.elements);
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/skycat.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/skycat.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/skycat.c	(revision 13409)
@@ -98,6 +98,6 @@
     graphmode.etype = 0;
     PrepPlotting (Npts, &graphmode);
-    PlotVector (Npts, Xvec.elements);
-    PlotVector (Npts, Yvec.elements);
+    PlotVector (Npts, Xvec.elements, "x");
+    PlotVector (Npts, Yvec.elements, "y");
   }
 
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/include/display.h
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/include/display.h	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/include/display.h	(revision 13409)
@@ -8,5 +8,5 @@
 int           GetCurrentDevice      PROTO((void));
 int           PrepPlotting          PROTO((int Npts, Graphdata *graphmode));
-int           PlotVector            PROTO((int, float *));
+int           PlotVector            PROTO((int Npts, float *values, char *type));
 int           PlotVectorTriplet     PROTO((int N, float *xValues, float *yValues, float *zValues, Graphdata *graphmode));
 int           GetGraphData          PROTO((Graphdata *data, int *kapa, char *name));
Index: /branches/kapa-mods-2007-05/Ohana/src/opihi/lib.data/PlotVectors.c
===================================================================
--- /branches/kapa-mods-2007-05/Ohana/src/opihi/lib.data/PlotVectors.c	(revision 13408)
+++ /branches/kapa-mods-2007-05/Ohana/src/opihi/lib.data/PlotVectors.c	(revision 13409)
@@ -10,7 +10,7 @@
 }
 
-int PlotVector (int Npts, float *values) {
+int PlotVector (int Npts, float *values, char *type) {
 
-  KapaPlotVector (kapa, Npts, values);
+  KapaPlotVector (kapa, Npts, values, type);
   return (TRUE);
 }
@@ -19,6 +19,6 @@
 
   PrepPlotting (N, graphmode);
-  PlotVector (N, xValues);
-  PlotVector (N, yValues);
+  PlotVector (N, xValues, "x");
+  PlotVector (N, yValues, "y");
 
   return (TRUE);
@@ -28,7 +28,7 @@
 
   PrepPlotting (N, graphmode);
-  PlotVector (N, xValues);
-  PlotVector (N, yValues);
-  PlotVector (N, zValues);
+  PlotVector (N, xValues, "x");
+  PlotVector (N, yValues, "y");
+  PlotVector (N, zValues, "z");
 
   return (TRUE);
