#!/bin/csh -f
#
# selopt2 -- part of the subselections item on the Other Options menu
#
# mod: Nov.2,1998 clh:  add ability to use 'OR' in list of selections
source build-opt-env

set POSTSTR=(`$OPTHOME/bin/poststring var op val combo`)
set op="$POSTSTR[2]"

#
# strpbrk searches op for either e or t, which will find
#  any of the following string operators:
#  lt,le,eq,ne,ge,gt,contains,is_contained_in,begins_with,ends_with
#
set found=`${OPTHOME}/bin/strpbrk "$op" "et"`
if ($found == "yes") then
# 
# the argument is a string operator, wrap it in blanks (%20)
#
   set op="%20$op%20"
else
   set op=`${OPTHOME}/bin/htmlesc "$POSTSTR[2]"`
endif

if ( "$QUERY_STRING" == "" ) then
  setenv QUERY_STRING "$POSTSTR[1]$op$POSTSTR[3]"
else 

 switch ("$POSTSTR[4]")
    case "AND"
      setenv QUERY_STRING $QUERY_STRING,"$POSTSTR[1]$op$POSTSTR[3]"
      breaksw
    case "OR"
      setenv QUERY_STRING $QUERY_STRING"|$POSTSTR[1]$op$POSTSTR[3]"
      breaksw
  endsw
endif


${OPTHOME}/${OPTRUNDIR}/selopt
