Index: /trunk/Ohana/src/opihi/cmd.data/queuedrop.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/queuedrop.c	(revision 8191)
+++ /trunk/Ohana/src/opihi/cmd.data/queuedrop.c	(revision 8192)
@@ -3,5 +3,6 @@
 int queuedrop (int argc, char **argv) {
   
-  int N, Key;
+  int N;
+  char *Key;
   char *var;
   char *line;
@@ -9,13 +10,12 @@
   Queue *queue;
 
-  Key = -1;
+  Key = NULL;
   if ((N = get_argument (argc, argv, "-key"))) {
     remove_argument (N, &argc, argv);
-    Key = atoi (argv[N]);
+    Key = strcreate (argv[N]);
     remove_argument (N, &argc, argv);
     Value = strcreate (argv[N]);
     remove_argument (N, &argc, argv);
   }
-
 
   if ((argc != 2) || (Key == -1)) {
Index: /trunk/Ohana/src/opihi/cmd.data/queuepop.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/queuepop.c	(revision 8191)
+++ /trunk/Ohana/src/opihi/cmd.data/queuepop.c	(revision 8192)
@@ -25,5 +25,4 @@
     remove_argument (N, &argc, argv);
   }
-
 
   if (argc != 2) {
Index: /trunk/Ohana/src/opihi/include/convert.h
===================================================================
--- /trunk/Ohana/src/opihi/include/convert.h	(revision 8191)
+++ /trunk/Ohana/src/opihi/include/convert.h	(revision 8192)
@@ -15,4 +15,6 @@
 int           day_to_sec            PROTO((char *string, time_t *second));
 int           hms_to_sec            PROTO((char *string, time_t *second));
+char         *sec_to_hms            PROTO((time_t second));
+char         *sec_to_day            PROTO((time_t second));
 
 char         *meade_deg_to_str      PROTO((double deg));
Index: /trunk/Ohana/src/opihi/include/pantasks.h
===================================================================
--- /trunk/Ohana/src/opihi/include/pantasks.h	(revision 8191)
+++ /trunk/Ohana/src/opihi/include/pantasks.h	(revision 8192)
@@ -51,5 +51,5 @@
   time_t stop;
   char type;
-  char keep;
+  char include;
   int Nmax;
   int Nrun;
Index: /trunk/Ohana/src/opihi/lib.data/convert.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.data/convert.c	(revision 8191)
+++ /trunk/Ohana/src/opihi/lib.data/convert.c	(revision 8192)
@@ -116,4 +116,50 @@
 }
 
+/***** convert seconds to HH:MM:SS ****/
+char *sec_to_hms (time_t second) {
+  
+  struct tm *gmt;
+  char *line;
+
+  ALLOCATE (line, char, 64);
+  gmt   = gmtime (&second);
+  sprintf (line, "%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 
+  return (line);
+}
+
+/***** convert seconds to Day@HH:MM:SS ****/
+char *sec_to_day (time_t second) {
+  
+  struct tm *gmt;
+  char *line;
+
+  ALLOCATE (line, char, 64);
+  gmt   = gmtime (&second);
+  switch (gmt[0].tm_wday) {
+    case 0:
+      sprintf (line, "Sun@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 
+      break;
+    case 1:
+      sprintf (line, "Mon@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 
+      break;
+    case 2:
+      sprintf (line, "Tue@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 
+      break;
+    case 3:
+      sprintf (line, "Wed@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 
+      break;
+    case 4:
+      sprintf (line, "Thu@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 
+      break;
+    case 5:
+      sprintf (line, "Fri@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 
+      break;
+    case 6:
+      sprintf (line, "Sat@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 
+      break;
+  }
+  return (line);
+}
+
 int hh_hm (double hh, int *hr, double *mn) {
 
Index: /trunk/Ohana/src/opihi/pantasks/CheckTimeRanges.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/CheckTimeRanges.c	(revision 8191)
+++ /trunk/Ohana/src/opihi/pantasks/CheckTimeRanges.c	(revision 8192)
@@ -1,9 +1,13 @@
 # include "pantasks.h"
+
+/* the tested time is saved by CheckTimeRanges for a following BumpTimeRanges
+   otherwise we could have an inconsistency between valid ranges and Nrun */
+static time_t daytime, weektime, abstime;
 
 /* test if we meet all time range qualifications */
 int CheckTimeRanges (TimeRange *ranges, int Nranges) {
 
-  int i, intime, valid;
-  time_t daytime, weektime, abstime, testtime;
+  int i, intime, Ninclude, include, exclude, valid;
+  time_t testtime;
   struct timeval now;
   struct tm Now;
@@ -16,6 +20,11 @@
   abstime  = now.tv_sec;
 
-  valid = TRUE;
-  for (i = 0; (i < Nranges) && valid; i++) {
+  Ninclude = 0;
+  include = FALSE;
+  exclude = FALSE;
+  
+  for (i = 0; i < Nranges; i++) {
+    if (ranges[i].include) Ninclude ++;
+
     switch (ranges[i].type) {
       /* set the testtime */
@@ -35,15 +44,20 @@
 
     /* check for more than max runs in time range */
-    if (ranges[i].keep && intime && ranges[i].Nmax) {
+    if (ranges[i].include && intime && ranges[i].Nmax) {
       if (ranges[i].Nrun >= ranges[i].Nmax) return (FALSE);
     }
     /* reset Nrun if we are outside of intime */
-    if (ranges[i].keep && !intime && ranges[i].Nmax && ranges[i].Nrun) {
+    if (ranges[i].include && !intime && ranges[i].Nmax && ranges[i].Nrun) {
       ranges[i].Nrun = 0;
     }
 
     /* is this a valid time? */
-    valid = ranges[i].keep ? intime : !intime;
+    if ( ranges[i].include &&  intime) include = TRUE;
+    if (!ranges[i].include && !intime) exclude = TRUE;
   }
+
+  if (Ninclude == 0) include = TRUE;
+  valid = include && !exclude;
+
   return (valid);
 }  
@@ -53,10 +67,30 @@
 int BumpTimeRanges (TimeRange *ranges, int Nranges) {
 
-  int i;
+  int i, intime;
+  time_t testtime;
 
+  /* only increment the counter for ranges which are valid */
   for (i = 0; i < Nranges; i++) {
-    if (ranges[i].keep && ranges[i].Nmax) {
-      ranges[i].Nrun ++;
+    if (!ranges[i].Nmax) continue;
+    if (!ranges[i].include) continue;
+
+    switch (ranges[i].type) {
+      /* set the testtime */
+      case RANGE_ABS:
+	testtime = abstime;
+	break;
+      case RANGE_DAY:
+	testtime = daytime;
+	break;
+      case RANGE_WEEK:
+	testtime = weektime;
+	break;
+      default:
+	abort ();
     }
+    intime = (testtime >= ranges[i].start) && (testtime <= ranges[i].stop);
+
+    /* reset Nrun if we are outside of intime */
+    if (intime) ranges[i].Nrun ++;
   }
   return (TRUE);
Index: /trunk/Ohana/src/opihi/pantasks/TaskOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/TaskOps.c	(revision 8191)
+++ /trunk/Ohana/src/opihi/pantasks/TaskOps.c	(revision 8192)
@@ -52,5 +52,6 @@
 void ListTasks (int verbose) {
 
-  int i, valid;
+  int i, j, valid;
+  char *start, *stop;
 
   gprint (GP_LOG, "\n");
@@ -78,4 +79,31 @@
       gprint (GP_LOG, "    spawn period: %f, polling period: %f, timeout period: %f\n", 
 	       tasks[i][0].exec_period, tasks[i][0].poll_period, tasks[i][0].timeout_period);
+      for (j = 0; j < tasks[i][0].Nranges; j++) {
+	switch (tasks[i][0].ranges[j].type) {
+	  case RANGE_ABS:
+	    start = sec_to_date (tasks[i][0].ranges[j].start);
+	    stop  = sec_to_date (tasks[i][0].ranges[j].stop);
+	    break;
+	  case RANGE_DAY:
+	    start = sec_to_hms (tasks[i][0].ranges[j].start);
+	    stop  = sec_to_hms (tasks[i][0].ranges[j].stop);
+	    break;
+	  case RANGE_WEEK:
+	    start = sec_to_day (tasks[i][0].ranges[j].start);
+	    stop  = sec_to_day (tasks[i][0].ranges[j].stop);
+	    break;
+	  default:
+	    abort ();
+	}
+	if (tasks[i][0].ranges[j].include) {
+	  gprint (GP_LOG, "     active : %s - %s", start, stop);
+	  if (tasks[i][0].ranges[j].Nmax) gprint (GP_LOG, " (%d of %d)", tasks[i][0].ranges[j].Nrun, tasks[i][0].ranges[j].Nmax);
+	  gprint (GP_LOG, "\n");
+	} else {
+	  gprint (GP_LOG, "     avoid  : %s - %s\n", start, stop);
+	}
+	free (start);
+	free (stop);
+      }
       if (tasks[i][0].host == NULL) {
 	gprint (GP_LOG, "    task runs locally\n");
@@ -99,5 +127,6 @@
 int ShowTask (char *name) {
 
-  int i;
+  int i, j;
+  char *start, *stop
   Task *task;
 
@@ -138,5 +167,33 @@
 periods:
   gprint (GP_LOG, " time periods: exec: %f  poll: %f  timeout: %f\n", 
-	   task[0].exec_period, task[0].poll_period, task[0].timeout_period);
+	  task[0].exec_period, task[0].poll_period, task[0].timeout_period);
+
+  for (j = 0; j < tasks[i][0].Nranges; j++) {
+    switch (tasks[i][0].ranges[j].type) {
+      case RANGE_ABS:
+	start = sec_to_date (tasks[i][0].ranges[j].start);
+	stop  = sec_to_date (tasks[i][0].ranges[j].stop);
+	break;
+      case RANGE_DAY:
+	start = sec_to_hms (tasks[i][0].ranges[j].start);
+	stop  = sec_to_hms (tasks[i][0].ranges[j].stop);
+	break;
+      case RANGE_WEEK:
+	start = sec_to_day (tasks[i][0].ranges[j].start);
+	stop  = sec_to_day (tasks[i][0].ranges[j].stop);
+	break;
+      default:
+	abort ();
+    }
+    if (tasks[i][0].ranges[j].include) {
+      gprint (GP_LOG, "     active : %s - %s", start, stop);
+      if (tasks[i][0].ranges[j].Nmax) gprint (GP_LOG, " (%d of %d)", tasks[i][0].ranges[j].Nrun, tasks[i][0].ranges[j].Nmax);
+      gprint (GP_LOG, "\n");
+    } else {
+      gprint (GP_LOG, "     avoid  : %s - %s\n", start, stop);
+    }
+    free (start);
+    free (stop);
+  }
 
   gprint (GP_LOG, "\n pre-execute macro\n");
Index: /trunk/Ohana/src/opihi/pantasks/task.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/task.c	(revision 8191)
+++ /trunk/Ohana/src/opihi/pantasks/task.c	(revision 8192)
@@ -23,13 +23,10 @@
   if ((N = get_argument (argc, argv, "-show"))) {
     remove_argument (N, &argc, argv);
+    if (argc != 2) goto usage;
     ShowTask (argv[N]);
     return (TRUE);
   }
 
-  if (argc != 2) {
-    gprint (GP_ERR, "USAGE: task <name>\n");
-    gprint (GP_ERR, "  (enter commands & task functions; end with the word 'END')\n");
-    return (FALSE);
-  }
+  if (argc != 2) goto usage;
 
   task = FindTask (argv[1]);
@@ -108,5 +105,11 @@
     }
   }
-  /* cannot ever reach here */
+
+usage:
+  gprint (GP_ERR, "USAGE: task -list\n");
+  gprint (GP_ERR, "USAGE: task -longlist\n");
+  gprint (GP_ERR, "USAGE: task -show (task)\n");
+  gprint (GP_ERR, "USAGE: task <name>\n");
+  gprint (GP_ERR, "  (enter commands & task functions; end with the word 'END')\n");
   return (FALSE);
 }
Index: /trunk/Ohana/src/opihi/pantasks/task_trange.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/task_trange.c	(revision 8191)
+++ /trunk/Ohana/src/opihi/pantasks/task_trange.c	(revision 8192)
@@ -7,12 +7,23 @@
   TimeRange range;
 
-  /* add a -reset option? 
-  if (N = get_argument (argc, argv, "-reset")) {
+  /* reset the tranges for the current task */
+  if ((N = get_argument (argc, argv, "-reset"))) {
     remove_argument (N, &argc, argv);
-  } */
+    if (argc != 1) goto usage;
+
+    task = GetNewTask ();
+    if (task == NULL) {
+      gprint (GP_ERR, "ERROR: not defining or running a task\n");
+      return (FALSE);
+    }
+
+    task[0].Nranges = 0;
+    REALLOCATE (task[0].ranges, TimeRange, 1);
+    return (TRUE);
+  } 
 
   range.Nmax = 0;
   range.Nrun = 0;
-  if (N = get_argument (argc, argv, "-nmax")) {
+  if ((N = get_argument (argc, argv, "-nmax"))) {
     remove_argument (N, &argc, argv);
     range.Nmax = atoi (argv[N]);
@@ -22,8 +33,8 @@
   /* keep = true means the time range defines a valid time range
      keep = false means the time range defines an invalid range */
-  range.keep = TRUE;
+  range.include = TRUE;
   if ((N = get_argument (argc, argv, "-exclude"))) {
     remove_argument (N, &argc, argv);
-    range.keep = FALSE;
+    range.include = FALSE;
   }
 
@@ -38,5 +49,8 @@
   /* test for Mon[@HH:MM:SS] - both must match */
   if (day_to_sec (argv[1], &range.start)) {
-    if (!day_to_sec (argv[2], &range.stop)) goto usage;
+    if (!day_to_sec (argv[2], &range.stop)) {
+      gprint (GP_ERR, "invalid day/time %s\n", argv[2]);
+      goto usage;
+    }
     range.type = RANGE_WEEK;
     goto valid;
@@ -45,5 +59,8 @@
   /* test for HH:MM:SS */
   if (hms_to_sec (argv[1], &range.start)) {
-    if (!hms_to_sec (argv[2], &range.stop)) goto usage;
+    if (!hms_to_sec (argv[2], &range.stop)) {
+      gprint (GP_ERR, "invalid time %s\n", argv[2]);
+      goto usage;
+    }
     range.type = RANGE_DAY;
     goto valid;
@@ -53,5 +70,8 @@
   /* test for YYYY/MM/DD - both must match */
   if (str_to_time (argv[1], &range.start)) {
-    if (!str_to_time (argv[2], &range.stop)) goto usage;
+    if (!str_to_time (argv[2], &range.stop)) {
+      gprint (GP_ERR, "invalid date/time %s\n", argv[2]);
+      goto usage;
+    }
     range.type = RANGE_ABS;
     goto valid;
@@ -68,5 +88,6 @@
 
 usage:
-  gprint (GP_ERR, "USAGE: trange start end\n");
+  gprint (GP_ERR, "USAGE: trange start end [-nmax N]\n");
+  gprint (GP_ERR, "USAGE: trange -reset\n");
   return (FALSE);
 }
