Index: trunk/gsdl/src/recpt/browsetools.cpp
===================================================================
--- trunk/gsdl/src/recpt/browsetools.cpp	(revision 1609)
+++ trunk/gsdl/src/recpt/browsetools.cpp	(revision 1610)
@@ -116,5 +116,5 @@
   textout << outconvert << disp 
 	  << get_formatted_string (args["c"],collectproto,
-				   response.docInfo[0], formatlistptr,
+				   response.docInfo[0], disp, formatlistptr,
 				   logout);
 }
Index: trunk/gsdl/src/recpt/datelistbrowserclass.cpp
===================================================================
--- trunk/gsdl/src/recpt/datelistbrowserclass.cpp	(revision 1609)
+++ trunk/gsdl/src/recpt/datelistbrowserclass.cpp	(revision 1610)
@@ -126,5 +126,5 @@
     textout << outconvert << disp 
             << get_formatted_string (collection, collectproto,
-				     *thissection, formatlistptr, 
+				     *thissection, disp, formatlistptr, 
 				     link, icon, false,
 				     logout) << "\n";
Index: trunk/gsdl/src/recpt/documentaction.cpp
===================================================================
--- trunk/gsdl/src/recpt/documentaction.cpp	(revision 1609)
+++ trunk/gsdl/src/recpt/documentaction.cpp	(revision 1610)
@@ -720,5 +720,5 @@
       text_t doctext 
       = get_formatted_string (collection, collectproto,
-			      docinfo, formatlistptr, docresponse.doc,
+			      docinfo, disp, formatlistptr, docresponse.doc,
 			      logout); 
       
Index: trunk/gsdl/src/recpt/formattools.cpp
===================================================================
--- trunk/gsdl/src/recpt/formattools.cpp	(revision 1609)
+++ trunk/gsdl/src/recpt/formattools.cpp	(revision 1610)
@@ -32,5 +32,6 @@
 // a few function prototypes
 static text_t format_string (const text_t& collection, recptproto* collectproto,
-			     ResultDocInfo_t &docinfo, format_t *formatlistptr,
+			     ResultDocInfo_t &docinfo, displayclass &disp, 
+			     format_t *formatlistptr,
 			     const text_t &link, const text_t &icon, 
 			     const text_t &text, bool highlight, ostream& logout);
@@ -49,4 +50,5 @@
   command = dMeta;
   meta.clear();
+  text.clear();
 }
 
@@ -385,13 +387,20 @@
 	text.clear();
 
-      } else {
-	// the {If}{decide,do,else} statement
+      } 
+
+      // Parse an {If}{decide,do,else} statement
+      else {
+	
+	// Read the decision component.  
 	if (commacount == 0) {
-	  // If decision only supports metadata at present
-
-	  // remove the surrounding square brackets
+	  // Decsion can be a metadata element, or a piece of text.
+	  // Originally Stefan's code, updated 25/10/2000 by Gordon.
+
 	  text_t::const_iterator beginbracket = text.begin();
 	  text_t::const_iterator endbracket = (text.end() - 1);
+
+	  // Decision is based on a metadata element
 	  if ((*beginbracket == '[') && (*endbracket == ']')) {
+	    // Ignore the surrounding square brackets
 	    text_t meta = substr (beginbracket+1, endbracket);
 	    parse_meta (meta, formatlistptr->decision.meta, metadata, getParents);
@@ -399,9 +408,19 @@
 	    text.clear();
 	  } 
-	  
-	} else {
+
+	  // Decision is a piece of text (probably a macro like _cgiargmode_).
+	  else {
+	    formatlistptr->decision.command = dText;
+	    formatlistptr->decision.text = text;
+	    commacount ++;
+	    text.clear();
+	  }
+	} 
+
+	// Read the "then" and "else" components of the {If} statement.
+	else {
 	  format_t** nextlistptr = NULL;
 	  if (commacount == 1) {
-	      nextlistptr = &formatlistptr->ifptr;
+	    nextlistptr = &formatlistptr->ifptr;
 	  } else if (commacount == 2 ) {
 	    nextlistptr = &formatlistptr->elseptr;
@@ -548,5 +567,6 @@
 
 static text_t get_or (const text_t& collection, recptproto* collectproto,
-		      ResultDocInfo_t &docinfo, format_t *orptr,
+		      ResultDocInfo_t &docinfo, displayclass &disp,
+		      format_t *orptr,
 		      const text_t &link, const text_t &icon, 
 		      const text_t &text, bool highlight,
@@ -556,6 +576,6 @@
   while (orptr != NULL) {
 
-    tmp = format_string (collection,collectproto, docinfo,orptr, 
-			 link,icon,text,highlight, logout);
+    tmp = format_string (collection,collectproto, docinfo, disp, orptr, 
+			 link, icon, text, highlight, logout);
     if (!tmp.empty()) return tmp;
 
@@ -566,5 +586,6 @@
 
 static text_t get_if (const text_t& collection, recptproto* collectproto,
-		      ResultDocInfo_t &docinfo, const decision_t &decision,
+		      ResultDocInfo_t &docinfo, displayclass &disp, 
+		      const decision_t &decision,
 		      format_t *ifptr, format_t *elseptr, const text_t &link, 
 		      const text_t &icon, const text_t &text, bool highlight,
@@ -572,17 +593,41 @@
 {
 
-  // not much of a choice yet ...
+  // If the decision component is a metadata element, then evaluate it
+  // to see whether we output the "then" or the "else" clause
   if (decision.command == dMeta) {
     if (get_meta (docinfo, decision.meta) != "") {
       if (ifptr != NULL)
-	return get_formatted_string (collection,collectproto, docinfo,ifptr, 
-				     link,icon,text,highlight, logout);
+	return get_formatted_string (collection,collectproto, docinfo, disp, ifptr, 
+				     link, icon, text, highlight, logout);
     }
     else {
       if (elseptr != NULL)
-	return get_formatted_string (collection,collectproto, docinfo,elseptr,
-				     link,icon,text,highlight, logout);
-    }
-  }
+	return get_formatted_string (collection,collectproto, docinfo, disp, elseptr,
+				     link, icon, text, highlight, logout);
+    }
+  }
+
+  // If the decision component is text, then evaluate it (it is probably a 
+  // macro like _cgiargmode_) to decide what to output.
+  else if (decision.command == dText) {
+
+    text_t outstring;
+    disp.expandstring (decision.text, outstring);
+
+    // This is a tad tricky.  When we expand a string like _cgiargmode_, that is
+    // a cgi argument macro that has not been set, it evaluates to itself.
+    // Therefore, were have to say that a piece of text evalautes true if
+    // it is non-empty and if it is a cgi argument evaulating to itself.
+    if ((outstring != "") && !((outstring == decision.text) && (outstring[0] == '_'))) {
+      if (ifptr != NULL)
+	return get_formatted_string (collection, collectproto, docinfo, disp, ifptr, 
+				     link, icon, text, highlight, logout);
+    } else {
+      if (elseptr != NULL)
+	return get_formatted_string (collection, collectproto, docinfo, disp, elseptr,
+				     link, icon, text, highlight, logout);
+    }
+  }
+  
   return "";
 }
@@ -601,5 +646,6 @@
 
 text_t format_string (const text_t& collection, recptproto* collectproto,
-		      ResultDocInfo_t &docinfo, format_t *formatlistptr,
+		      ResultDocInfo_t &docinfo, displayclass &disp, 
+		      format_t *formatlistptr,
 		      const text_t &link, const text_t &icon, 
 		      const text_t &text, bool highlight,
@@ -644,6 +690,6 @@
 	    {
 	      text_t expanded_metavalue
-		= get_formatted_string(collection,collectproto, 
-				       response.docInfo[0],expanded_formatlistptr, 
+		= get_formatted_string(collection, collectproto, 
+				       response.docInfo[0], disp, expanded_formatlistptr, 
 				       link,icon,highlight,
 				       logout);
@@ -670,11 +716,11 @@
     break;
   case comIf:
-    return get_if (collection, collectproto, 
-		   docinfo, formatlistptr->decision, formatlistptr->ifptr, 
+    return get_if (collection, collectproto, docinfo, disp, 
+		   formatlistptr->decision, formatlistptr->ifptr, 
 		   formatlistptr->elseptr, link, icon, text, highlight,
 		   logout);
   case comOr:
-    return get_or (collection,collectproto, docinfo,formatlistptr->orptr, 
-		   link,icon,text,highlight, logout);
+    return get_or (collection,collectproto, docinfo, disp, formatlistptr->orptr, 
+		   link, icon, text, highlight, logout);
   }
   return "";
@@ -685,5 +731,6 @@
 
 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
-			     ResultDocInfo_t& docinfo, format_t* formatlistptr,
+			     ResultDocInfo_t& docinfo, displayclass &disp,
+			     format_t* formatlistptr,
 			     const text_t& link, const text_t& icon, 
 			     const text_t& text, const bool highlight,
@@ -693,5 +740,5 @@
   while (formatlistptr != NULL) 
     {
-      ft += format_string (collection, collectproto, docinfo, formatlistptr, 
+      ft += format_string (collection, collectproto, docinfo, disp, formatlistptr, 
 			   link, icon, text, highlight, logout);
       formatlistptr = formatlistptr->nextptr;
@@ -702,5 +749,6 @@
 
 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
-			     ResultDocInfo_t &docinfo, format_t *formatlistptr,
+			     ResultDocInfo_t &docinfo, displayclass &disp,
+			     format_t *formatlistptr,
 			     const text_t &link, const text_t &icon, 
 			     const bool highlight,
@@ -709,10 +757,11 @@
   text_t text = "";
 
-  return get_formatted_string(collection, collectproto, docinfo, formatlistptr,
+  return get_formatted_string(collection, collectproto, docinfo, disp, formatlistptr,
                               link, icon, text, highlight, logout);
 }
 
 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
-			     ResultDocInfo_t &docinfo, format_t *formatlistptr,
+			     ResultDocInfo_t &docinfo, displayclass &disp,
+			     format_t *formatlistptr,
 			     const text_t& text,
 			     ostream& logout) {
@@ -722,16 +771,23 @@
   bool highlight = false;
 
-  return get_formatted_string(collection, collectproto, docinfo, formatlistptr,
+  return get_formatted_string(collection, collectproto, docinfo, disp, formatlistptr,
 			      link, icon, text, highlight, logout);
 }
 
 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
-			     ResultDocInfo_t &docinfo, format_t *formatlistptr,
+			     ResultDocInfo_t &docinfo, displayclass &disp,
+			     format_t *formatlistptr,
 			     ostream& logout) {
 
   text_t text = "";
 
-  return get_formatted_string(collection, collectproto, docinfo, formatlistptr,
+  return get_formatted_string(collection, collectproto, docinfo, disp, formatlistptr,
 			      text, logout);
 }
 
+
+
+
+
+
+
Index: trunk/gsdl/src/recpt/formattools.h
===================================================================
--- trunk/gsdl/src/recpt/formattools.h	(revision 1609)
+++ trunk/gsdl/src/recpt/formattools.h	(revision 1610)
@@ -31,9 +31,10 @@
 #include "comtypes.h"
 #include "recptproto.h"
+#include "display.h"
 
 enum command_t {comIf, comOr, comMeta, comText, comLink, comEndLink, comNum, comIcon, 
 		comDoc, comHighlight, comEndHighlight};
 enum pcommand_t {pNone, pImmediate, pTop, pAll};
-enum dcommand_t {dMeta};
+enum dcommand_t {dMeta, dText};
 enum mcommand_t {mNone, mCgiSafe};
 
@@ -48,4 +49,8 @@
 };
 
+
+// The decision component of an {If}{decision,true-text,false-text}
+// formatstring.  Te decision can be based on metadata or on text;
+// normally that text would be a macro like _cgiargmode_.  --gordon
 struct decision_t {
   void clear();
@@ -54,4 +59,5 @@
   dcommand_t command;
   metadata_t meta;
+  text_t text;
 };
 
@@ -102,5 +108,6 @@
 
 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
-			     ResultDocInfo_t &docinfo, format_t *formatlistptr,
+			     ResultDocInfo_t &docinfo, displayclass &disp,
+			     format_t *formatlistptr,
 			     const text_t &link, const text_t &icon, 
 			     const text_t& t, const bool highlight, 
@@ -108,5 +115,6 @@
 
 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
-			     ResultDocInfo_t &docinfo, format_t *formatlistptr,
+			     ResultDocInfo_t &docinfo, displayclass &disp,
+			     format_t *formatlistptr,
 			     const text_t &link, const text_t &icon, 
 			     const bool highlight,
@@ -114,11 +122,12 @@
 
 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
-			     ResultDocInfo_t &docinfo, format_t *formatlistptr,
+			     ResultDocInfo_t &docinfo, displayclass &disp, 
+			     format_t *formatlistptr,
 			     const text_t &text,
 			     ostream& logout);
 
 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
-			     ResultDocInfo_t &docinfo, format_t *formatlistptr,
-			     ostream& logout);
+			     ResultDocInfo_t &docinfo, displayclass &disp, 
+			     format_t *formatlistptr, ostream& logout);
 
 
Index: trunk/gsdl/src/recpt/hlistbrowserclass.cpp
===================================================================
--- trunk/gsdl/src/recpt/hlistbrowserclass.cpp	(revision 1609)
+++ trunk/gsdl/src/recpt/hlistbrowserclass.cpp	(revision 1610)
@@ -137,5 +137,5 @@
     textout << outconvert << disp 
 	    << get_formatted_string (collection, collectproto,
-				     *tsibling, formatlistptr, link, icon, highlight,
+				     *tsibling, disp, formatlistptr, link, icon, highlight,
 				     logout);
 
Index: trunk/gsdl/src/recpt/vlistbrowserclass.cpp
===================================================================
--- trunk/gsdl/src/recpt/vlistbrowserclass.cpp	(revision 1609)
+++ trunk/gsdl/src/recpt/vlistbrowserclass.cpp	(revision 1610)
@@ -82,5 +82,5 @@
   textout << outconvert << disp 
 	  << get_formatted_string (collection, collectproto, 
-				   section, formatlistptr, 
+				   section, disp, formatlistptr, 
 				   link, icon, highlight, logout);
   
@@ -133,5 +133,5 @@
     textout << outconvert << disp 
 	    << get_formatted_string (collection, collectproto, 
-				     *thissection, formatlistptr, 
+				     *thissection, disp, formatlistptr, 
 				     link, icon, highlight, logout);
 
