Index: trunk/ippTasks/survey.pro
===================================================================
--- trunk/ippTasks/survey.pro	(revision 30257)
+++ trunk/ippTasks/survey.pro	(revision 30376)
@@ -367,10 +367,12 @@
 # user functions to manipulate publish labels
 macro survey.add.publish
-  if ($0 != 3)
-    echo "USAGE: survey.add.publish (label) (client_id)"
+  if ($0 != 5)
+    echo "USAGE: survey.add.publish (tag) (label) (client_id) (comment)"
     break
   end
   book newpage SURVEY_PUBLISH $1
-  book setword SURVEY_PUBLISH $1 CLIENT_ID $2
+  book setword SURVEY_PUBLISH $1 LABEL $2
+  book setword SURVEY_PUBLISH $1 CLIENT_ID $3
+  book setword SURVEY_PUBLISH $1 COMMENT $4
   book setword SURVEY_PUBLISH $1 STATE PENDING
 end
@@ -1089,13 +1091,15 @@
     endif
 
-    book getpage SURVEY_PUBLISH 0 -var label -key STATE NEW
-    if ("$label" == "NULL")
-      # All labels have been done --- reset
-      # echo "Resetting labels"
+    # survey.publish allows multiple entries per label.
+    # The key is called tag and must be unique
+    book getpage SURVEY_PUBLISH 0 -var tag -key STATE NEW
+    if ("$tag" == "NULL")
+      # All tags have been done --- reset
+      # echo "Resetting tags"
       for i 0 $N
-        book getpage SURVEY_PUBLISH $i -var label
-	book setword SURVEY_PUBLISH $label STATE NEW
+        book getpage SURVEY_PUBLISH $i -var tag
+	book setword SURVEY_PUBLISH $tag STATE NEW
       end
-      book getpage SURVEY_PUBLISH 0 -var label -key STATE NEW
+      book getpage SURVEY_PUBLISH 0 -var tag -key STATE NEW
 
       # Select different database
@@ -1104,8 +1108,14 @@
     end
 
-    book setword SURVEY_PUBLISH $label STATE DONE
-    book getword SURVEY_PUBLISH $label CLIENT_ID -var client_id
+    book setword SURVEY_PUBLISH $tag STATE DONE
+    book getword SURVEY_PUBLISH $tag LABEL -var label
+    book getword SURVEY_PUBLISH $tag CLIENT_ID -var client_id
+    book getword SURVEY_PUBLISH $tag COMMENT -var comment
   
     $run = pubtool -definerun -label $label -client_id $client_id
+
+    if ("$comment" != "NULL") 
+        $run = $run -comment $comment
+    end
 
     if ($DB:n == 0)
@@ -1116,6 +1126,8 @@
     end
     
-    #echo $run
+    echo $run
+
     command $run
+    
   end
 
