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

proc colCurrent {w colu} {



	upvar #0 EZRcol col
	upvar #0 EZRcolatts colatts
	upvar #0 EZRcols cols
	upvar #0 EZRtype type
	upvar #0 EZRind ind
	upvar #0 EZRwhere where
	upvar #0 EZRop op
	upvar #0 EZRcomp1 comp1
	upvar #0 EZRcomp2 comp2


	set buts {eq ne gt lt ge le bt st en ct in}
	set ops {= != > < >= <= bet sta end con in}

#	clear the old setup from the comparison panel

	clearEZRspec 


	set col $colu

	set type [keylget colatts($colu) type]
	set cl [keylget colatts($colu) size]

	set cw 0
#	EZRwidths may not be set yet if this is first time through

	set err [catch {keylget colatts($colu) width}]
	if {$err} {
	} else {
	}

	if {($type == "char" ) || ($type == "varchar")} {
        set type [format "%s(%s)" $type $cl] 
	}

	$w.data.spec.cf configure -text "$col"
	$w.data.spec.type configure -text "$type"

	if {$cw} {
	$w.data.spec.wid delete 0 end
	$w.data.spec.wid insert 0 "$cw"
	} else {
	$w.data.spec.wid delete 0 end
	}
#
#	at this point we should figure out the type and disable operators
#	that should not be used
#
	set ct [getType $type]

	case $ct in {
	{S} {
#	char, date or varchar
#        foreach b {eq ne gt lt ge le bt in st ct en} {
#                $w.data.spec.$b configure -state normal
#        }
	$w.messages configure -text "To restrict the value of $colu, choose any comparison operator from the bar above and enter values as directed."
	}
	{I F} {
#	numbers of some kind, or text/image blobs
#	$w.data.spec.st configure -state disabled
#	$w.data.spec.ct configure -state disabled
#	$w.data.spec.en configure -state disabled
	$w.messages configure -text "You can't use Starting, Containing, and Ending comparisons with numeric values."
	}
	{U} {
#	foreach b {eq ne gt lt ge le bt in st ct en} {
#                $w.data.spec.$b configure -state normal
#        }
	$w.messages configure -text "Warning, this is a user defined data type and you should know what it is before comparing."
	}
	{N} {

#	foreach b {eq ne gt lt ge le bt in st ct en} {
#		$w.data.spec.$b configure -state disabled
#	}
	$w.messages configure -text "We cannot do any comparisons on this data type : $type"
	$w.data.spec.require configure -text "$col impossible"
	return
	}
	}

	$w.data.spec.require configure -text "$col should be:"

#	Does a where clause exist for this column?
	set err [catch {set where($col,op)}]

	if {$err == 0} {
		set op $where($col,op)
		set but [lindex $buts [lsearch $ops $op]]
		if {$but != ""} {$w.data.spec.$but configure -border 1}
#		No need, text var controls it
#		$w.data.spec.cmp1 delete 0 end  
#		$w.data.spec.cmp1 insert 0 "$where($col,c1)"
		set comp1 "$where($col,c1)"
#		No need, text var controls it
#		$w.data.spec.cmp2 delete 0 end  
		if {$where($col,c2) != ""} {
		set comp2 "$where($col,c2)"
		$w.data.spec.and configure -text "and"
#		no need, text var controls it
#		$w.data.spec.cmp2 insert 0 "$where($col,c2)"
		$w.data.spec.cmp2 configure -border 1
		$w.messages configure  -text "Enter two comparison values"
 		} else {
		$w.data.spec.and configure -text " "
                $w.data.spec.cmp2 delete 0 end
                $w.data.spec.cmp2 configure -border 0
		}
	} 

}

