Index: trunk/ippTasks/automate.pro
===================================================================
--- trunk/ippTasks/automate.pro	(revision 17576)
+++ trunk/ippTasks/automate.pro	(revision 17577)
@@ -3,7 +3,9 @@
 # example automation stage
 # automate METADATA
-#   name       STR DARK
-#   check      STR "detselect -search -inst SIMTEST -det_type BIAS -dbname eamtest"
-#   launch     STR "dettool -definebyquery -workdir path://EAMWORK -inst SIMTEST -det_type DARK -select_exp_type DARK -dbname eamtest"
+#  name       STR DARK
+#  check      STR "detselect -search -inst SIMTEST -det_type BIAS -dbname eamtest"
+#  ncheck     S32 1
+#  launch     STR "dettool -definebyquery -workdir path://EAMWORK -inst SIMTEST -det_type DARK -select_exp_type DARK -dbname eamtest"
+#  block      STR "dettool -runs -active -det_type DARK -dbname eamtest"
 # END
 
@@ -15,15 +17,14 @@
 # DONE (action finished)
 
-# XXX since the state is ephemeral, any stages for which the prereq
-# exists will be re-launched every time this tasks is loaded in
-# pantasks.  We can add a 'block' stage to test if a given stage has
-# already been performed or not...
-
 macro load.automate
-  if ($0 != 2)
-    echo "USAGE: load.automate (filename)"
+  if ($0 != 3)
+    echo "USAGE: load.automate (filename) (dbname)"
     break
   end
   queueload tmp -x "cat $MODULES:0/$1"
+
+  ## interpolate standard values
+  queuesubstr tmp @DBNAME@ $2
+
   ipptool2book tmp automate -key name -uniq -setword pantaskState INIT.BLOCK
   queuedelete tmp
@@ -219,6 +220,10 @@
     end
 
+    book getword automate $pageName ncheck -var Ncheck
+    if ("$Ncheck" == "NULL")
+      $Ncheck = 1
+    end 
     book npages tmpCheck -var Npage 
-    if ($Npage == 0) 
+    if ($Npage < $Ncheck) 
       if ($VERBOSE >= 2) 
         echo "$pageName not ready for LAUNCH"
