# $Header: /home/cvsroot/tcldb/wisql/Tlib/chkOp,v 1.3 1997/08/28 05:24:09 de Exp $
# tcl procs saved on Tue Sep 05 09:32:23 PDT 1995

proc chkOp {w but op} {



	upvar #0 EZRcol col
	upvar #0 EZRcolatts colatts
	upvar #0 EZRop gop


	set trans(sta) "starts with"
	set trans(end) "ends with"
	set trans(con) "contains"

	set type [keylget colatts($col) type]
	set ct [getType $type]

	if {$ct == "N"} {
		$w.messages configure -text "No, you cannot place any requirements on a field of type $type -- pick another field."
		return
	}

#	Now here is a question, should selection of a new op clear the
#	parameter entry space or leave it alone?

	if {$w == "."} {
		set w ""
	}

	case $op in {
	{bet} {
		$w.data.spec.cmp1 configure -width 10
		$w.data.spec.and configure -text "and"
		$w.data.spec.cmp2 configure -state normal
		$w.data.spec.cmp2 configure -width 10 -border 1
		$w.messages configure  -text "$col between X and Y : Enter two comparison values"
		bind $w.data.spec.cmp1 <KeyPress-Return> "focus $w.data.spec.cmp2"
		bind $w.data.spec.cmp2 <KeyPress-Return> "$w.data.spec.go invoke"
	}  
	{in} {
		$w.messages configure  -text "$col in A B C D E... : Enter a list of values to find $col in"
		$w.data.spec.and configure -text "   " -width 3
		$w.data.spec.cmp2 configure -width 2 -border 0 
		$w.data.spec.cmp2 delete 0 end
		$w.data.spec.cmp2 configure -state disabled
#		$w.data.spec.cmp1 configure -width 30
		bind $w.data.spec.cmp1 <KeyPress-Return> "$w.data.spec.go invoke"
	}
	{sta con end} {
		case $ct in {
		{S} {
		$w.data.spec.cmp1 configure -width 10
		$w.data.spec.and configure -text "   " -width 3
		$w.data.spec.cmp2 delete 0 end
		$w.data.spec.cmp2 configure -width 10 -border 0
		$w.data.spec.cmp2 configure -state disabled
		$w.messages configure  -text "$col $trans($gop) X : Enter one comparison value"
		bind $w.data.spec.cmp1 <KeyPress-Return> "$w.data.spec.go invoke"
		}
		{default} {
		$w.messages configure  -text "Sorry, you can't use starts, contains or ends except with strings and dates."
		set gop ""
		}
		}
	}
	{default} {
		$w.data.spec.cmp1 configure -width 10
		$w.data.spec.and configure -text "   " -width 3
		$w.data.spec.cmp2 delete 0 end
		$w.data.spec.cmp2 configure -width 10 -border 0 
		$w.data.spec.cmp2 configure -state disabled
		$w.messages configure  -text "$col $gop X : Enter one comparison value"
		bind $w.data.spec.cmp1 <KeyPress-Return> "$w.data.spec.go invoke"
	}
	}

#	always return the cursor to cmp1 whenever op changes.

	focus $w.data.spec.cmp1
	$w.data.spec.cmp1 icursor end
}

