Index: trunk/ippTasks/phase0.pro
===================================================================
--- trunk/ippTasks/phase0.pro	(revision 11236)
+++ trunk/ippTasks/phase0.pro	(revision 11323)
@@ -28,5 +28,7 @@
 end
 
-$phase0_DB = 0
+# these variables will cycle through the known database names
+$p0PendingImfile_DB = 0
+$p0PendingExp_DB = 0
 
 # select images ready for phase0 analysis
@@ -39,7 +41,5 @@
   periods      -exec $loadexec
   periods      -timeout 30
-
-  # XXX test that this option works
-#  npending     1
+  npending     1
 
   # silently drop stdout
@@ -48,12 +48,15 @@
 
   # select entries from the current DB; cycle to the next DB, if it exists
-  # if the DB list is not set, use the value defined in .ipprc
+  # iff the DB list is not set, use the value defined in .ipprc
   task.exec
     if ($DB:n == 0)
+      option DEFAULT
       command p0tool -pendingimfile -limit 20
     else
-      command p0tool -pendingimfile -limit 20 -dbname $DB:$phase0_DB
-      $phase0_DB ++
-      if ($phase0_DB >= $DB:n) set phase0_DB = 0
+      # save the DB name for the exit tasks
+      option $DB:$p0PendingImfile_DB
+      command p0tool -pendingimfile -limit 20 -dbname $DB:$p0PendingImfile_DB
+      $p0PendingImfile_DB ++
+      if ($p0PendingImfile_DB >= $DB:n) set p0PendingImfile_DB = 0
     end
   end
@@ -62,5 +65,5 @@
   task.exit $EXIT_SUCCESS
     # convert 'stdout' to book format
-    ipptool2book stdout p0PendingImfile -key exp_tag -uniq
+    ipptool2book stdout p0PendingImfile -key exp_tag -uniq -setword dbname $options:0
     if ($VERBOSE > 2)
       book listbook p0PendingImfile
@@ -105,5 +108,6 @@
     book getword p0PendingImfile $pageName uri -var URI
     book getword p0PendingImfile $pageName workdir -var WORKDIR
-#    book getword p0PendingImfile $pageName dbname -var DBNAME
+    book getword p0PendingImfile $pageName dbname -var DBNAME
+    set_standard_args
 
     # specify choice of remote host
@@ -114,5 +118,5 @@
     end
 
-    ## generate output log based on filerule
+    ## generate output log based on filerule XXX put this in a function?
     $outroot = $WORKDIR/$EXP_TAG
     $logfile = `ipp_filename.pl PHASE0.LOG $outroot $CLASS_ID`
@@ -126,7 +130,7 @@
     # create the command line
     if ($VERBOSE > 1)
-      echo command phase0_imfile.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI
-    end
-    command phase0_imfile.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI
+      echo command phase0_imfile.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI $ARGS
+    end
+    command phase0_imfile.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI $ARGS
   end
 
@@ -155,11 +159,20 @@
 
   task.exec
-    command p0tool -pendingexp -limit 20
+    if ($DB:n == 0)
+      option DEFAULT
+      command p0tool -pendingexp -limit 20
+    else
+      # save the DB name for the exit tasks
+      option $DB:$p0PendingExp_DB
+      command p0tool -pendingexp -limit 20 -dbname $DB:$p0PendingExp_DB
+      $p0PendingExp_DB ++
+      if ($p0PendingExp_DB >= $DB:n) set p0PendingExp_DB = 0
+    end
   end
 
   # success
-  task.exit    0
+  task.exit $EXIT_SUCCESS
     # convert 'stdout' to book format
-    ipptool2book stdout p0PendingExp -key exp_tag -uniq
+    ipptool2book stdout p0PendingExp -key exp_tag -uniq -setword dbname $options:0
     if ($VERBOSE > 2)
       book listbook p0PendingExp
@@ -200,4 +213,6 @@
     book getword p0PendingExp $pageName exp_tag -var EXP_TAG
     book getword p0PendingExp $pageName workdir -var WORKDIR
+    book getword p0PendingExp $pageName dbname -var DBNAME
+    set_standard_args
 
     # specify choice of remote host:(need to choose based on chips)
@@ -220,7 +235,7 @@
     # create the command line
     if ($VERBOSE > 1)
-      echo command phase0_exp.pl --exp_tag $EXP_TAG
-    end
-    command phase0_exp.pl --exp_tag $EXP_TAG
+      echo command phase0_exp.pl --exp_tag $EXP_TAG $ARGS
+    end
+    command phase0_exp.pl --exp_tag $EXP_TAG $ARGS
   end
 
