Index: branches/eam_branch_00/ippTasks/detrend.reject.pro
===================================================================
--- branches/eam_branch_00/ippTasks/detrend.reject.pro	(revision 10761)
+++ branches/eam_branch_00/ippTasks/detrend.reject.pro	(revision 11011)
@@ -1,17 +1,4 @@
-
 ## this file contains the tasks for running the detrend processing stage
 
-# dettool -residdetrun -simple
-# 1      0    bias
-# DET_ID ITER TYPE
-
-# detrend_reject_exp.pl 1      0    bias
-# detrend_reject_exp.pl DET_ID ITER TYPE
-
-## these tasks use the queue DetrendResidExp
-## the DetrendRejectExp queue contains:
-## STATE DET_ID ITER TYPE
-
-queueinit DetrendRejectExp
 if ($?network == 0)
   $network = 1
@@ -20,7 +7,4 @@
   $parallel = 0
 end
-
-$DetrendRejectExpFail = 0
-
 if ($?VERBOSE == 0)
   echo "VERBOSE not defined: load pantasks.pro first"
@@ -31,10 +15,12 @@
   break
 end
+
 $LOGSUBDIR = $LOGDIR/detrend
 exec mkdir -p $LOGSUBDIR
 
+book init DetrendRejectExp
+
 macro detreject.status
-  queueprint DetrendRejectExp
-  echo "DetrendRejectExpFail: $DetrendRejectExpFail"
+  book listbook DetrendRejectExp
 end
 
@@ -53,30 +39,17 @@
 
   task.exec
-    command dettool -residdetrun -simple -limit {$DetrendRejectExpFail + 20}
+    command dettool -residdetrun -limit 20
   end
 
   # success
   task.exit    0
-    local i Nqueue
-
-    # compare output with newImage queue
-    # only add entries which don't exist in queue
-    queuesize stdout -var Nqueue
-    for i 0 $Nqueue
-      queuepop stdout -var line
-      if ($VERBOSE > 2)
-        echo $line
-      end
-      list word -split $line
-      $DET_ID   = $word:0
-      $ITER     = $word:1
-      $DET_TYPE = $word:2
-      $MODE     = $word:3
-      $CAMERA   = $word:4
-      queuepush DetrendRejectExp -uniq -key 1:2 "NEW $DET_ID $ITER $DET_TYPE $MODE $CAMERA"
+    # convert 'stdout' to book format
+    ipptool2book stdout DetrendRejectExp -key det_id:iter -uniq
+    if ($VERBOSE > 2)
+      book listbook DetrendRejectExp
     end
 
     # delete existing entries which are DONE
-    queuedrop DetrendRejectExp -key 0 DONE
+    book delpage DetrendRejectExp -key state DONE
   end
 
@@ -99,30 +72,18 @@
 
   task.exec
-    queuesize DetrendRejectExp -var N
+    book npages DetrendRejectExp -var N
     if ($N == 0) break
     if ($network == 0) break
     
-    # look for new images on the internal DetrendRejectExp queue
-    # caution with these 'if' statements: syntax errors 
-    # will make the task fail without given a good status
-    queuepop DetrendRejectExp -var line -key 0 NEW
-    if ("$line" == "NULL") break
+    # look for new images in DetrendRejectExp
+    book getpage DetrendRejectExp 0 -var pageName -key state NULL
+    if ($pageName == NULL) break
 
-    strpop line state
-    queuepush DetrendRejectExp -replace -key 1:2 "RUN $line"
-
-    ## the DetrendRejectExp queue contains:
-    ## STATE DET_ID ITER TYPE
-    ## NOTE: the queue has the STATE prepended 
-    list word -split $line
-    $DET_ID   = $word:0
-    $ITER     = $word:1
-    $DET_TYPE = $word:2
-    $MODE     = $word:3
-    $CAMERA   = $word:4
-
-    # I'd like to add CAMERA to the log file...
-    stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
-    stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
+    book setword DetrendRejectExp $pageName state RUN
+    book getword DetrendRejectExp $pageName DET_ID   -var DET_ID   
+    book getword DetrendRejectExp $pageName ITER     -var ITER     
+    book getword DetrendRejectExp $pageName DET_TYPE -var DET_TYPE 
+    book getword DetrendRejectExp $pageName MODE     -var MODE     
+    book getword DetrendRejectExp $pageName CAMERA   -var CAMERA   
 
     # specify choice of remote host:
@@ -133,6 +94,12 @@
     end
 
+    # I'd like to add CAMERA to the log file...
+    stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
+    stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
+
+    # save the pageName for future reference below
+    options $pageName
+
     # create example job options as a demonstration
-    options "$line"
     if ($VERBOSE > 1)
       echo command detrend_reject_exp.pl --det_id $DET_ID --iteration $ITER --det_type $DET_TYPE --camera $CAMERA
@@ -143,5 +110,5 @@
   # success
   task.exit 0
-    queuepush DetrendRejectExp -replace -key 1:2 "DONE $options:0"
+    book setword DetrendRejectExp $options:0 state DONE
   end
 
@@ -149,6 +116,5 @@
   task.exit    default
     showcommand failure
-    queuepush DetrendRejectExp -replace -key 1:2 "FAIL $options:0"
-    $DetrendRejectExpFail ++
+    book setword DetrendRejectExp $options:0 state FAIL
   end
 
@@ -156,6 +122,5 @@
   task.exit    timeout
     showcommand failure
-    queuepush DetrendRejectExp -replace -key 1:2 "TIMEOUT $options:0"
-   $DetrendRejectExpFail ++
+    book setword DetrendRejectExp $options:0 state TIMEOUT
   end
 end
